MCPcopy Create free account
hub / github.com/bywwcnll/StreamPanel / initDB

Function initDB

devtools/modules/connectionStorageManager.js:9–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7let db = null;
8
9export async function initDB() {
10 if (db) return db;
11
12 return new Promise((resolve, reject) => {
13 const request = indexedDB.open(DB_NAME, DB_VERSION);
14
15 request.onerror = () => reject(request.error);
16 request.onsuccess = () => {
17 db = request.result;
18 resolve(db);
19 };
20
21 request.onupgradeneeded = (event) => {
22 try {
23 const db = event.target.result;
24 if (!db.objectStoreNames.contains(STORE_NAME)) {
25 const store = db.createObjectStore(STORE_NAME, { keyPath: 'id' });
26 store.createIndex('originalId', 'originalId', { unique: false });
27 store.createIndex('savedAt', 'savedAt', { unique: false });
28 store.createIndex('url', 'url', { unique: false });
29 }
30 } catch (upgradeError) {
31 console.error('[IndexedDB Upgrade] Error during database upgrade:', upgradeError);
32 }
33 };
34 });
35}
36
37export async function saveConnection(connectionData, options = {}) {
38 const database = await initDB();

Callers 7

saveConnectionFunction · 0.70
loadConnectionFunction · 0.70
deleteConnectionFunction · 0.70
deleteAllConnectionsFunction · 0.70
getAllSavedConnectionsFunction · 0.70
isConnectionSavedFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected