Fixed database init loop
This commit is contained in:
parent
1b03ae875b
commit
a08b0c4eea
@ -3,7 +3,8 @@
|
|||||||
<script type="module">
|
<script type="module">
|
||||||
import {Cache, Database} from './dist/index.mjs';
|
import {Cache, Database} from './dist/index.mjs';
|
||||||
|
|
||||||
const db = new Database('test', []);
|
const db = new Database('test', [123]);
|
||||||
|
window['table'] = db.table(123);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/utils",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.25.6",
|
"version": "0.25.7",
|
||||||
"description": "Utility library",
|
"description": "Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -12,7 +12,10 @@ export class Database {
|
|||||||
constructor(public readonly database: string, tables: (string | TableOptions)[], public version?: number) {
|
constructor(public readonly database: string, tables: (string | TableOptions)[], public version?: number) {
|
||||||
this.connection = new Promise((resolve, reject) => {
|
this.connection = new Promise((resolve, reject) => {
|
||||||
const req = indexedDB.open(this.database, this.version);
|
const req = indexedDB.open(this.database, this.version);
|
||||||
this.tables = tables.map(t => typeof t == 'object' ? t : {name: t});
|
this.tables = tables.map(t => {
|
||||||
|
t = typeof t == 'object' ? t : {name: t};
|
||||||
|
return {...t, name: t.name.toString()};
|
||||||
|
});
|
||||||
const tableNames = new ASet(this.tables.map(t => t.name));
|
const tableNames = new ASet(this.tables.map(t => t.name));
|
||||||
|
|
||||||
req.onerror = () => reject(req.error);
|
req.onerror = () => reject(req.error);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user