Javascript IndexedDB。如何在光标移动时更新记录

Javascript IndexedDB。如何在光标移动时更新记录,javascript,indexeddb,Javascript,Indexeddb,在同步方法中,我打开一个游标并向服务器发送Ajax帖子。我需要同时将记录“flag”设置为synchronized var transaction = db.transaction([STORE],IDBTransaction.READ_WRITE); transaction.objectStore(STORE).openCursor().onsuccess = function(e){ var cursor = e.target.result; if(cursor){

在同步方法中,我打开一个游标并向服务器发送Ajax帖子。我需要同时将记录“flag”设置为synchronized

var transaction = db.transaction([STORE],IDBTransaction.READ_WRITE);
transaction.objectStore(STORE).openCursor().onsuccess = function(e){
    var cursor = e.target.result;
    if(cursor){
        if (cursor.value.flag == "0") {

            //sync method                               
            cursor.update(cursor.value.flag = "1")  // not working

        };              
        cursor.continue();
    };
}; 
我如何才能做到这一点?

试试:

cursor.value.flag = "1";
cursor.update(cursor.value);
尝试:


当然cursor.value是整个对象,更改属性->更新对象。谢谢。当然。。。cursor.value是整个对象,更改属性->更新对象。谢谢