@bbn/bbn 2.0.230 → 2.0.232
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bbn.js +3 -3
- package/dist/bbn.js.map +1 -1
- package/dist/bbn.sw.js +1 -1
- package/dist/bbn.sw.js.map +1 -1
- package/dist/db.d.ts +0 -1
- package/dist/db.js +9 -21
- package/package.json +1 -1
package/dist/db.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ interface DbManager {
|
|
|
34
34
|
ok: boolean;
|
|
35
35
|
open(name: string, version?: number): Promise<IDbApi>;
|
|
36
36
|
add(database: string, name: string, structure: DbStructure): Promise<boolean>;
|
|
37
|
-
openRaw(name: string, version?: number): Promise<IDBDatabase>;
|
|
38
37
|
remove(database: string, name: string): Promise<void>;
|
|
39
38
|
updateStructure(storeName: string, structure: DbStructure, database: IDBDatabase): void;
|
|
40
39
|
importStructure(database: string, structure: Record<string, DbStructure>): Promise<void>;
|
package/dist/db.js
CHANGED
|
@@ -308,6 +308,7 @@ class DbObject {
|
|
|
308
308
|
}
|
|
309
309
|
let connection = yield this.getConnection();
|
|
310
310
|
if (!connection.objectStoreNames.contains(target)) {
|
|
311
|
+
connection.close();
|
|
311
312
|
yield db.add(this.dbName, target, this.structure[table]);
|
|
312
313
|
connection = yield this.getConnection();
|
|
313
314
|
}
|
|
@@ -318,7 +319,9 @@ class DbObject {
|
|
|
318
319
|
if (!rows.length) {
|
|
319
320
|
return 0;
|
|
320
321
|
}
|
|
321
|
-
|
|
322
|
+
const res = yield this.insert(target, rows);
|
|
323
|
+
connection.close();
|
|
324
|
+
return res;
|
|
322
325
|
});
|
|
323
326
|
}
|
|
324
327
|
deleteTable(table) {
|
|
@@ -455,12 +458,11 @@ const db = {
|
|
|
455
458
|
this._structures[database] = {};
|
|
456
459
|
}
|
|
457
460
|
this._structures[database][name] = structure;
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
if (!hadConn) {
|
|
461
|
-
yield this.open(database);
|
|
461
|
+
if (this._connections[database]) {
|
|
462
|
+
throw new Error(_('Database %s is already open. Close it before adding a new store.', database));
|
|
462
463
|
}
|
|
463
|
-
|
|
464
|
+
yield this.open(database);
|
|
465
|
+
let conn = this._connections[database];
|
|
464
466
|
// DB exists already: open temporarily and check if store exists
|
|
465
467
|
const hasStore = conn.objectStoreNames.contains(name);
|
|
466
468
|
if (!hasStore) {
|
|
@@ -470,24 +472,10 @@ const db = {
|
|
|
470
472
|
}
|
|
471
473
|
conn = this._connections[database];
|
|
472
474
|
}
|
|
473
|
-
|
|
474
|
-
this.close(database);
|
|
475
|
-
}
|
|
475
|
+
this.close(database);
|
|
476
476
|
return true;
|
|
477
477
|
});
|
|
478
478
|
},
|
|
479
|
-
openRaw(name, version) {
|
|
480
|
-
return new Promise((resolve, reject) => {
|
|
481
|
-
if (!idb) {
|
|
482
|
-
reject(new Error(_('IndexedDB is not available')));
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
const req = version ? idb.open(name, version) : idb.open(name);
|
|
486
|
-
req.onsuccess = () => resolve(req.result);
|
|
487
|
-
req.onerror = () => reject(req.error);
|
|
488
|
-
req.onblocked = () => reject(new Error(_('IndexedDB open blocked for database %s', name)));
|
|
489
|
-
});
|
|
490
|
-
},
|
|
491
479
|
remove(database, name) {
|
|
492
480
|
return __awaiter(this, void 0, void 0, function* () {
|
|
493
481
|
const currentStructure = this._structures[database];
|