jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.4k stars 360 forks source link

DeleteDB not working. Angular 7 #118

Closed abizit closed 5 years ago

abizit commented 5 years ago

I am using it on Angular 7 and i am not able to delete the DB. This is how i am trying to run it in Typescript.

 async deleteDatabase() {
        return await deleteDB(this.dbName);
    }

I am not being able to make it work. When i use the vanilla way using indexedDB.deleteDatabase(name); it says blocked.

jakearchibald commented 5 years ago

You need to close all connections before the database can be deleted.

geoidesic commented 5 years ago

Fair enough but there's nothing in the docs about how to close a database? Also this doesn't cause any errors.. just nothing happens.

abizit commented 5 years ago

Fair enough but there's nothing in the docs about how to close a database? Also this doesn't cause any errors.. just nothing happens.

I got it working like this..

const db = await openDB(name, version, { ... });
db.close();
await deleteDB(name);