@ztimson/utils 0.25.5 → 0.25.7
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/database.d.ts +2 -2
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -395,12 +395,16 @@ function makeArray(value) {
|
|
|
395
395
|
class Database {
|
|
396
396
|
constructor(database, tables, version) {
|
|
397
397
|
__publicField(this, "connection");
|
|
398
|
+
__publicField(this, "tables");
|
|
398
399
|
this.database = database;
|
|
399
|
-
this.tables = tables;
|
|
400
400
|
this.version = version;
|
|
401
401
|
this.connection = new Promise((resolve, reject) => {
|
|
402
402
|
const req = indexedDB.open(this.database, this.version);
|
|
403
|
-
|
|
403
|
+
this.tables = tables.map((t) => {
|
|
404
|
+
t = typeof t == "object" ? t : { name: t };
|
|
405
|
+
return { ...t, name: t.name.toString() };
|
|
406
|
+
});
|
|
407
|
+
const tableNames = new ASet(this.tables.map((t) => t.name));
|
|
404
408
|
req.onerror = () => reject(req.error);
|
|
405
409
|
req.onsuccess = () => {
|
|
406
410
|
const db = req.result;
|
|
@@ -421,7 +425,7 @@ class Database {
|
|
|
421
425
|
});
|
|
422
426
|
}
|
|
423
427
|
includes(name) {
|
|
424
|
-
return this.tables.
|
|
428
|
+
return !!this.tables.find((t) => t.name == name.toString());
|
|
425
429
|
}
|
|
426
430
|
table(name) {
|
|
427
431
|
return new Table(this, name.toString());
|