Dexie.version()
Syntax
db.version(versionNumber)Parameters
Note the backend DB will get the given version number multiplied by 10. See Issue #59 where the reason for this behavior is described.
Return Value
Version
Sample
This sample shows how to upgrade your database. Assume your first app defines version 1 of the database like this:
var db = new Dexie("FriendsAndPetsDatabase");
db.version(1).stores({
friends: "++id,name,age",
pets: "++id,name,kind"
});
db.open();
// Do some application logic on the database:
db.transaction("rw", db.friends, db.pets, function () {
db.friends.add({name: "David", age: 40, sex: "male"});
db.friends.add({name: "Ylva", age: 39, sex: "female"});
db.pets.add({name: "Josephina", kind: "dog"});
db.friends.where("name").equalsIgnoreCase("david").each(function(friend) {
console.log("Found friend: " + friend.name);
});
db.pets.where("kind").anyOf("dog", "cat").each(function(pet) {
console.log("Found dog or cat: " + pet.name);
});
}).catch (function (e) {
console.error(e.stack || e);
});Then you realise "age" was not a good thing to store because it will change as time goes by. You want to redesign your app to store birthdate instead. Here is how version 2 of your released app would look:
See Also
Database Versioning
Version.stores()
Version.upgrade()