-
-
Notifications
You must be signed in to change notification settings - Fork 641
Version.upgrade()
David Fahlander edited this page Mar 27, 2014
·
12 revisions
version.upgrade (upgraderFunction);
upgraderFunction: Function | Callback function with signature function(transaction){} where transaction is an instance of WriteableTransaction |
var db = new Dexie("FriendsAndPetsDatabase");
db.version(1).stores({
friends: "++id,name,age,sex"
});
db.version(2).stores({
friends: "++id,name,birthdate,sex"
}).upgrade (function (trans) {
var YEAR = 365 * 24 * 60 * 60 * 1000;
trans.friends.each (function (friend, cursor) {
friend.birthdate = new Date(Date.now() - (friend.age * YEAR));
delete friend.age;
cursor.update (friend);
});
});
db.open();
Dexie.js - minimalistic and bullet proof indexedDB library