indexeddb - 在 IndexedDB 中调用 add 或 put 时如何找出导致 ConstraintError 的索引?
问题描述
每当使用创建索引时,调用 add 或 put 时都可以返回unique=true
a 。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.'}
,和火狐:
{name:'ConstraintError', message: 'A mutation operation in the transaction failed because a constraint was not satisfied.'}
很明显,浏览器知道导致错误的索引。
但是有没有人知道有什么方法可以找到它?
解决方案
推荐阅读
- c# - 反射:在基类中调用派生属性 getter
- python - 将数组 (k,) 或 (k, n) 乘以一维数组 (k,)
- javascript - 寻找 ReactJS 库来创建流程/图表
- c# - 从带有信息的字符串创建具有初始化属性的对象列表
- c# - 调试 IEnumerable:获取 Iterator 块的当前行号
- java - 如何解决 java.sql.SQLException:在数据库与 JDBC API 的集成中?
- laravel - Laravel 与自定义键关系的多对多关系
- java - Mirth/Java10 - 缺少发送电子邮件的类
- heroku - 生产中缺少字段类型
- java - SpringBoot 和 GitLab CI 运行测试