dannyconnell / localbase

A Firebase-Style Database ... Offline!
623 stars 85 forks source link

Version Control #68

Open CrawfordW opened 2 years ago

CrawfordW commented 2 years ago

Great work Danny! Makes using indexedDB very easy. But what about version control? Can you suggest a way to recognize that the DB version is not what the app version needs and make the necessary updates to the DB?

samuk190 commented 3 weeks ago

Hi! I'm maintaining this project as Danny is a bit busy, I think its very possible to do that


var open = indexedDB.open("MyDatabase", 1);

console.log(value);

// Create the schema
open.onupgradeneeded = function(e) {
    console.log("Old Version: " + e.target.result.oldversion); //Undefined
    console.log("New Version: " + e.target.result.newversion); //Undefined
    var db = open.result;
    var store = db.createObjectStore("Inspections", {keyPath: "id", autoIncrement: true});
    var index = store.createIndex(key, key);
};

we could implement something like this, and return to localBase, something like

localBase.getVersion ?