【发布时间】:2020-06-29 15:51:19
【问题描述】:
我已经编写了几个函数来使用 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."
我该如何解决这个问题?错误背后的根本原因是什么?
【问题讨论】:
标签: javascript reactjs indexeddb dexie