Trying to update a records name field but instead of updating the record it creates a new record.
My Code
function editName(e) {
var transaction = db.transaction(["people"],"readwrite");
var store = transaction.objectStore("people");
var request = store.get(5);
request.onsuccess = function(e) {
var data = e.target.result;
data.name = "John";
var objRequest = store.put(data);
objRequest.onsuccess = function(e){
console.log('Success in updating record');
};
}
}
Looking for record 5 and attempting to change it's name field to John. I have been following Raymond Camden tutorial http://code.tutsplus.com/tutorials/working-with-indexeddb-part-2--net-35355 and searched for other examples like IndexedDB update by id but can't seem to adapt them to work for what I need.