Use native IndexedDB to delete the database

This commit is contained in:
toasted-nutbread 2019-11-03 15:56:00 -05:00
parent 3a1e3392ed
commit 183ec6b381

View File

@ -81,8 +81,9 @@ class Database {
this.db = {
backendDB: () => idb,
close: () => {}, // Not implemented
delete: () => {} // Not implemented
close: () => idb.close(),
get name() { return idb.name; },
set name(v) {}
};
}
@ -90,7 +91,7 @@ class Database {
this.validate();
this.db.close();
await this.db.delete();
await Database.deleteDatabase(this.db.name);
this.db = null;
await this.prepare();
@ -815,4 +816,12 @@ class Database {
}
}
}
static deleteDatabase(dbName) {
return new Promise((resolve, reject) => {
const request = indexedDB.deleteDatabase(dbName);
request.onerror = (e) => reject(e);
request.onsuccess = () => resolve();
});
}
}