Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 表未包含在父事务中-Dexie_Javascript_Reactjs_Indexeddb_Dexie - Fatal编程技术网

Javascript 表未包含在父事务中-Dexie

Javascript 表未包含在父事务中-Dexie,javascript,reactjs,indexeddb,dexie,Javascript,Reactjs,Indexeddb,Dexie,我已经编写了两个函数来使用Dexie包装器操作indexedDB中的数据。这是更新方法: updateRow(documentId, rowId, row) { this.db.transaction('rw', this.db.tableEntry, async () => { await this.db.tableEntry.where({ documentId: documentId,

我已经编写了两个函数来使用Dexie包装器操作indexedDB中的数据。这是更新方法:

updateRow(documentId, rowId, row) {
        this.db.transaction('rw', this.db.tableEntry, async () => {
            await this.db.tableEntry.where({
                documentId: documentId,
                rowId: rowId
            }).modify({row: row})
        }).catch(e => {
            console.log(e)
        });
    }
此函数的工作原理与预期完全相同。以下函数在同一类中以相同的方式实现:

getAllByDocumentId(documentId, callBack) {
        this.db.transaction('rw', this.db.tableEntry, async () => {
            await this.db.tableEntry.where({
                documentId: documentId,
            }).toArray((entries)=>callBack(entries))
        }).catch(e => {
            console.log(e)
        });
    }
执行此方法会产生以下错误:

name: "SubTransactionError"
message: "Table tableEntry not included in parent transaction."

我怎样才能解决这个问题?错误背后的根本原因是什么?

我发现原因是,其他调用类执行多个包含事务的函数。因此,这些异步函数与它们的事务重叠。由于这个原因,只有第一个函数调用成功。我使用的简单方法是在调用时延迟函数的执行

update(...);
setTimeout(getAllByDocumentId(...),200);
setTimeout(otherDBFunction(...),300);
然后它工作得很好