IndexedDB update by id -
i'm trying update indexeddb records error
dataerror: info provided operation not meet requirements. source file
i tried this don't worked
this function:
function updnotes(text, timestamp, blob) { var obj = {text: text, timestamp: timestamp}; if (typeof blob != 'undefined') obj.image = blob; store = getobjectstore("notes", 'readwrite'); objkeyrange = idbkeyrange.only(+objtoedit); req = store.opencursor(objkeyrange); req.onsuccess = function(evt){ var cursor = evt.target.result; console.log(cursor.key); //do update var objrequest = cursor.update(obj); objrequest.onsuccess = function(ev){ console.log('success'); }; objrequest.onerror = function(ev){ console.log('error'); }; }; req.onerror = function(evt){ console.log('error'); };
anyone can help me prepare ?
best regards
i figure out how this. function solved problem.
function updnotes(id, text, timestamp, blob) { console.log(id); store = getobjectstore("notes", 'readwrite'); req = store.get(+id); req.onsuccess = function(evt){ var info = evt.target.result; data.text = text; data.timestamp = timestamp; if (typeof blob != 'undefined') data.image = blob; //do update var objrequest = store.put(data); objrequest.onsuccess = function(ev){ console.log('success in updating record'); }; objrequest.onerror = function(ev){ console.log('error in updating record'); }; }; req.onerror = function(evt){ console.log('error in retrieving record'); }; }
indexeddb
No comments:
Post a Comment