WebSQL-to-IndexedDB-example icon indicating copy to clipboard operation
WebSQL-to-IndexedDB-example copied to clipboard

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

Open Humphrey-Huang opened this issue 12 years ago • 2 comments

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));
    };

Humphrey-Huang avatar Jul 04 '13 08:07 Humphrey-Huang

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!

greenido avatar Jul 04 '13 12:07 greenido

closing... ✔️

greenido1 avatar Aug 20 '19 19:08 greenido1