As a basic example, I click a button then a record is entered into the indexeddb objectstore. I now want to knockout observable updated with the new record.
The code below works. However, I am wondering if this is the right way to do it. The "getAll" function is a IndexedDB-getAll-shim that I found.
self.addPersonRecord = function(){
// item being added
data = {name: "Some User", email: "aa2314123@something.com" };
var obj = db.transaction(["people"], "readwrite").objectStore("people");
var req = obj.add(data);
// result of save
req.onsuccess = function(event) {
// get all items from db
obj.getAll().onsuccess = function (ev) {
// update observable
self.chosenPageData({people: ev.target.result});
};
};
};