Skip to content
Discussion options

You must be logged in to vote

If you would be okay with clearing all data in all tables for any user on version before 91, you can do like this:

db.version(91).upgrade(tx => {
    for (const table of tx.storeNames) {
        tx.table(table).clear();
    }
});

Anyone on version 90 or below will hit this code and get all their data cleared. This is not exactly the same as db.delete() but in practice, it's the same effect.

If hard database delete is important for you, the following would also work but feels a bit more hacky:

db.version(91).upgrade(() => {
  db.on('ready', () => {
    db.delete().then(()=>db.open());
  }
});

That said, I've seen this requirement before and I think a built-in solution into dexie would be n…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@laukaichung
Comment options

Answer selected by laukaichung
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants