MCPcopy
hub / github.com/jakearchibald/idb / openDBWithData

Function openDBWithData

test/utils.ts:52–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50let dbWithDataCreated = false;
51
52export async function openDBWithData() {
53 if (dbWithDataCreated) return openDB<TestDBSchema>(dbName, version);
54 dbWithDataCreated = true;
55 const db = await openDBWithSchema();
56 const tx = db.transaction(['key-val-store', 'object-store'], 'readwrite');
57 const keyStore = tx.objectStore('key-val-store');
58 const objStore = tx.objectStore('object-store');
59 keyStore.put(123, 'foo');
60 keyStore.put(456, 'bar');
61 keyStore.put(789, 'hello');
62 objStore.put({
63 id: 1,
64 title: 'Article 1',
65 date: new Date('2019-01-04'),
66 });
67 objStore.put({
68 id: 2,
69 title: 'Article 2',
70 date: new Date('2019-01-03'),
71 });
72 objStore.put({
73 id: 3,
74 title: 'Article 3',
75 date: new Date('2019-01-02'),
76 });
77 objStore.put({
78 id: 4,
79 title: 'Article 4',
80 date: new Date('2019-01-01'),
81 });
82 return db;
83}
84
85export function deleteDatabase(callbacks: DeleteDBCallbacks = {}) {
86 version = 0;

Callers 2

iterate.tsFile · 0.90
main.tsFile · 0.90

Calls 5

openDBFunction · 0.90
openDBWithSchemaFunction · 0.85
transactionMethod · 0.80
objectStoreMethod · 0.80
putMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…