MCPcopy Create free account
hub / github.com/TanStack/db / getDatababase

Function getDatababase

packages/rxdb-db-collection/tests/rxdb.test.ts:38–76  ·  view source on GitHub ↗
(
    initialDocs: Array<TestDocType> = [],
    dbId = dbNameId++,
  )

Source from the content-addressed store, hash-verified

36 }
37
38 async function getDatababase(
39 initialDocs: Array<TestDocType> = [],
40 dbId = dbNameId++,
41 ) {
42 const db = await createRxDatabase<RxCollections, unknown, unknown, unknown>(
43 {
44 name: `my-rxdb-` + dbId,
45 ignoreDuplicate: true,
46 storage: wrappedValidateAjvStorage({
47 storage: getRxStorageMemory(),
48 }),
49 },
50 )
51 const collections = await db.addCollections<RxCollections>({
52 test: {
53 schema: {
54 version: 0,
55 type: `object`,
56 primaryKey: `id`,
57 properties: {
58 id: {
59 type: `string`,
60 maxLength: 100,
61 },
62 name: {
63 type: `string`,
64 maxLength: 9,
65 },
66 },
67 },
68 },
69 })
70 const rxCollection: RxCollection<TestDocType> = collections.test
71 if (initialDocs.length > 0) {
72 const insertResult = await rxCollection.bulkInsert(initialDocs)
73 expect(insertResult.error.length).toBe(0)
74 }
75 return db
76 }
77
78 async function createTestState(
79 initialDocs: Array<TestDocType> = [],

Callers 2

createTestStateFunction · 0.85
rxdb.test.tsFile · 0.85

Calls 1

expectFunction · 0.90

Tested by

no test coverage detected