Skip to content

Instantly share code, notes, and snippets.

@delebash
Forked from skratchdot/dexieDeleteAllDbs.js
Created September 19, 2021 01:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delebash/25802fb524a792791dccb26880b4220b to your computer and use it in GitHub Desktop.
Save delebash/25802fb524a792791dccb26880b4220b to your computer and use it in GitHub Desktop.
Delete all Dexie.js databases
Dexie.getDatabaseNames(function (names, cb) {
console.log('database names: ', names);
names.forEach(function (name) {
var db = new Dexie(name);
db.delete().then(function() {
console.log('Database successfully deleted: ', name);
}).catch(function (err) {
console.error('Could not delete database: ', name, err);
}).finally(function() {
console.log('Done. Now executing callback if passed.');
if (typeof cb === 'function') {
cb();
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment