-
-
Notifications
You must be signed in to change notification settings - Fork 647
Dexie.on.versionchange
David Fahlander edited this page Apr 6, 2016
·
12 revisions
db.on("versionchange", function (event) {});
The "versionchange" event occurs if another indexedDB database instance with a newer version of the database needs to upgrade the database. If you do not subscribe to this event, Dexie has a built-in default implementation that will close the database immediately and fire a VersionChangeError error event to db.on('error'). This will resume the upgrading process of the other page.
To override the default behavior, your subscriber function must return false.
var db = new Dexie("MyDB");
db.on("versionchange", function(event) {
if (!confirm ("Another page tries to upgrade the database to version " +
event.newVersion + ". Accept?")) {
return false;
}
};
Dexie.js - minimalistic and bullet proof indexedDB library