无法获取indexedDB中新插入的记录

时间:2018-07-10 06:06:25

标签: javascript indexeddb

最近添加新记录时,我遇到了麻烦。刷新页面时,我会得到最近添加的记录。

在IndexedDB中获取记录的示例代码:

get(id, storeName, callback) {
            var trans = this.db.transaction([storeName], "readwrite");
            var store = trans.objectStore(storeName);
            try{
                var process = await store.get(id);
            }catch(ex){}
            trans.oncomplete = function(event){
                callback(process !== undefined ? process.result : null);
                delete process;
                delete trans;
                delete store;
                delete go;
            };
            trans.onerror = function(){
                callback(null);
            };
}

我收到未定义的错误,因为它似乎未获取新添加的记录。我该如何解决这个问题?

0 个答案:

没有答案