在调用add或put-in-IndexedDB时,如何找出导致错误的索引?
无论何时使用在调用add或put-in-IndexedDB时,如何找出导致错误的索引?,indexeddb,Indexeddb,无论何时使用unique=true创建索引,调用add或put时都可以返回constraint 可以从IDBReaquest.error读取的错误是一个DOMEException,它没有足够的信息。以下是Chrome的回报: {name:'ConstraintError', message: 'Unable to add key to index 'country-city': at least one key does not satisfy the uniqueness requiremen
unique=true
创建索引,调用add或put时都可以返回constraint
可以从IDBReaquest.error
读取的错误是一个DOMEException
,它没有足够的信息。以下是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.'}
很明显,浏览器知道导致错误的索引
但有人知道找到答案的方法吗