WebSQL-to-IndexedDB-example
WebSQL-to-IndexedDB-example copied to clipboard
The request.onupgradeneeded part, db.version === dbVersion
Seems when this function is invoked, the db.version has been changed. So, I try to change codes as followed, please check:
request.onupgradeneeded = function(e) {
todoDB.indexedDB.db = e.target.result;
var db = todoDB.indexedDB.db;
console.log ("Going to upgrade our DB from version: "+ e.oldVersion + " to " + e.newVersion);
if(db.objectStoreNames.contains("todo")) {
db.deleteObjectStore("todo");
}
var store = db.createObjectStore("todo", {keyPath: "timeStamp"});
console.log("-- onupgradeneeded store:"+ JSON.stringify(store));
};
Could you please have a look at the changes that I've made to the code? I guess it was the objectStoreNames that coz it. Thanks!
closing... ✔️