@bbn/bbn 2.0.232 → 2.0.234
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 +1 -1
- 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 +21 -0
- package/dist/db.js +8 -3
- package/package.json +1 -1
package/dist/db.d.ts
CHANGED
|
@@ -27,9 +27,30 @@ interface IDbApi {
|
|
|
27
27
|
copyTable(target: string, table: string, fields?: string[], where?: unknown, order?: OrderClause, start?: number, limit?: number | null): Promise<number>;
|
|
28
28
|
deleteTable(table: string): Promise<boolean>;
|
|
29
29
|
}
|
|
30
|
+
declare class DbObject implements IDbApi {
|
|
31
|
+
private readonly dbName;
|
|
32
|
+
private lastErr;
|
|
33
|
+
constructor(dbName: string);
|
|
34
|
+
private hasMissingStores;
|
|
35
|
+
private getConnection;
|
|
36
|
+
private get structure();
|
|
37
|
+
private getStore;
|
|
38
|
+
lastError(): unknown;
|
|
39
|
+
close(): void;
|
|
40
|
+
insert(table: string, data: Record<string, unknown> | Record<string, unknown>[]): Promise<number>;
|
|
41
|
+
update(table: string, data: Record<string, unknown>, where: WhereObject, replace?: boolean): Promise<number>;
|
|
42
|
+
delete(table: string, where: Record<string, unknown>): Promise<number>;
|
|
43
|
+
selectOne(table: string, field: string, where?: unknown, order?: OrderClause, start?: number, limit?: number): Promise<unknown>;
|
|
44
|
+
select(table: string, fields?: string[], where?: unknown, order?: OrderClause, start?: number): Promise<Record<string, unknown> | null>;
|
|
45
|
+
selectAll(table: string, fields?: string[], where?: unknown, order?: OrderClause, start?: number, limit?: number | null): Promise<Record<string, unknown>[]>;
|
|
46
|
+
getColumnValues(table: string, field: string, where?: unknown, order?: OrderClause, start?: number, limit?: number | null): Promise<unknown[]>;
|
|
47
|
+
copyTable(target: string, table: string, fields?: string[], where?: unknown, order?: OrderClause, start?: number, limit?: number | null): Promise<number>;
|
|
48
|
+
deleteTable(table: string): Promise<boolean>;
|
|
49
|
+
}
|
|
30
50
|
interface DbManager {
|
|
31
51
|
_structures: DbStructures;
|
|
32
52
|
_connections: Record<string, IDBDatabase>;
|
|
53
|
+
_objects: Record<string, DbObject>;
|
|
33
54
|
_stores: Record<string, unknown>;
|
|
34
55
|
ok: boolean;
|
|
35
56
|
open(name: string, version?: number): Promise<IDbApi>;
|
package/dist/db.js
CHANGED
|
@@ -334,6 +334,7 @@ class DbObject {
|
|
|
334
334
|
const db = {
|
|
335
335
|
_structures: {},
|
|
336
336
|
_connections: {},
|
|
337
|
+
_objects: {},
|
|
337
338
|
_stores: {},
|
|
338
339
|
ok: idb !== undefined,
|
|
339
340
|
close(database) {
|
|
@@ -342,6 +343,9 @@ const db = {
|
|
|
342
343
|
conn.close();
|
|
343
344
|
delete this._connections[database];
|
|
344
345
|
}
|
|
346
|
+
if (this._objects[database]) {
|
|
347
|
+
delete this._objects[database];
|
|
348
|
+
}
|
|
345
349
|
},
|
|
346
350
|
updateStructure(storeName, structure, database) {
|
|
347
351
|
const primary = getPrimaryKey(structure);
|
|
@@ -422,8 +426,8 @@ const db = {
|
|
|
422
426
|
if (!this._structures[database]) {
|
|
423
427
|
throw new Error(_('Impossible to find a structure for the database %s', database));
|
|
424
428
|
}
|
|
425
|
-
if (this.
|
|
426
|
-
return
|
|
429
|
+
if (this._objects[database]) {
|
|
430
|
+
return this._objects[database];
|
|
427
431
|
}
|
|
428
432
|
yield new Promise((resolve, reject) => {
|
|
429
433
|
const req = version ? idb.open(database, version) : idb.open(database);
|
|
@@ -445,7 +449,8 @@ const db = {
|
|
|
445
449
|
reject(_('open: Upgrade blocked for database %s. Please close other connections to proceed.', database));
|
|
446
450
|
};
|
|
447
451
|
});
|
|
448
|
-
|
|
452
|
+
this._objects[database] = new DbObject(database);
|
|
453
|
+
return this._objects[database];
|
|
449
454
|
});
|
|
450
455
|
},
|
|
451
456
|
add(database, name, structure) {
|