greenido / WebSQL-to-IndexedDB-example

Todo list example to show how to convert WebSQL to IndexedDB
36 stars 17 forks source link

The request.onupgradeneeded part, db.version === dbVersion #4

Open Humphrey-Huang opened 11 years ago

Humphrey-Huang commented 11 years ago

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));
    };
greenido commented 11 years ago

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!

greenido1 commented 5 years ago

closing... ✔️