最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - IndexedDB. How to update records as cursor moves - Stack Overflow

programmeradmin1浏览0评论

In a synchronization method I´m opening a cursor and sending Ajax posts to server. I need at the same time to set the record "flag" to 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();
    };
}; 

How can I do this?

In a synchronization method I´m opening a cursor and sending Ajax posts to server. I need at the same time to set the record "flag" to 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();
    };
}; 

How can I do this?

Share Improve this question asked Dec 23, 2012 at 17:34 Ruben TeixeiraRuben Teixeira 5742 gold badges8 silver badges17 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

try:

cursor.value.flag = "1";
cursor.update(cursor.value);
发布评论

评论列表(0)

  1. 暂无评论