如何在调用added或puted in IndexedDB时找出引起ConstraintError的索引?

时间:2019-05-15 10:33:40

标签: indexeddb

无论何时使用unique=true创建索引,调用add或put都可以返回ConstraintError

可以从IDBReaquest.error读取的错误是DOMException,它没有足够的信息。这是Chrome返回的内容:

{name:'ConstraintError', message: 'Unable to add key to index 'country-city': at least one key does not satisfy the uniqueness requirements.'}

和Firefox:

{name:'ConstraintError', message: 'A mutation operation in the transaction failed because a constraint was not satisfied.'}

显然,浏览器知道导致错误的索引。

但是有人知道如何找到它吗?

0 个答案:

没有答案