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

Function initDB

devtools/panel.bundle.js:199–225  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

197 let db = null;
198
199 async function initDB() {
200 if (db) return db;
201
202 return new Promise((resolve, reject) => {
203 const request = indexedDB.open(DB_NAME, DB_VERSION);
204
205 request.onerror = () => reject(request.error);
206 request.onsuccess = () => {
207 db = request.result;
208 resolve(db);
209 };
210
211 request.onupgradeneeded = (event) => {
212 try {
213 const db = event.target.result;
214 if (!db.objectStoreNames.contains(STORE_NAME)) {
215 const store = db.createObjectStore(STORE_NAME, { keyPath: 'id' });
216 store.createIndex('originalId', 'originalId', { unique: false });
217 store.createIndex('savedAt', 'savedAt', { unique: false });
218 store.createIndex('url', 'url', { unique: false });
219 }
220 } catch (upgradeError) {
221 console.error('[IndexedDB Upgrade] Error during database upgrade:', upgradeError);
222 }
223 };
224 });
225 }
226
227 async function saveConnection(connectionData, options = {}) {
228 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