@bbn/bbn 2.0.232 → 2.0.233
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 +6 -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) {
|
|
@@ -341,6 +342,7 @@ const db = {
|
|
|
341
342
|
if (conn) {
|
|
342
343
|
conn.close();
|
|
343
344
|
delete this._connections[database];
|
|
345
|
+
delete this._objects[database];
|
|
344
346
|
}
|
|
345
347
|
},
|
|
346
348
|
updateStructure(storeName, structure, database) {
|
|
@@ -422,8 +424,8 @@ const db = {
|
|
|
422
424
|
if (!this._structures[database]) {
|
|
423
425
|
throw new Error(_('Impossible to find a structure for the database %s', database));
|
|
424
426
|
}
|
|
425
|
-
if (this.
|
|
426
|
-
return
|
|
427
|
+
if (this._objects[database]) {
|
|
428
|
+
return this._objects[database];
|
|
427
429
|
}
|
|
428
430
|
yield new Promise((resolve, reject) => {
|
|
429
431
|
const req = version ? idb.open(database, version) : idb.open(database);
|
|
@@ -445,7 +447,8 @@ const db = {
|
|
|
445
447
|
reject(_('open: Upgrade blocked for database %s. Please close other connections to proceed.', database));
|
|
446
448
|
};
|
|
447
449
|
});
|
|
448
|
-
|
|
450
|
+
this._objects[database] = new DbObject(database);
|
|
451
|
+
return this._objects[database];
|
|
449
452
|
});
|
|
450
453
|
},
|
|
451
454
|
add(database, name, structure) {
|