Resources
Some important links:
How Do I...
- Prevent conflicts / duplicates
- Easiest is to specify a unique key, with the
&
prefix in the schema definition - If you want to allow duplicates a majority of the time, but in one instance only insert if data is not already there (e.g. when running a seeder), you can use
put
operations (modifies if already existing, inserts if not), lookup manually before inserting, or use an in-between table to track seeding runs.
- Easiest is to specify a unique key, with the
Tips and Tricks
- Be careful / thoughtful when using transactions (
.transaction()
) and debugging related issues- For example, you might get
specified object store was not found
error if you forget to explicitly pass in a table that you try to use inside the transaction.
- For example, you might get
- If you get an error like
"Failed to execute 'put' on 'IDBObjectStore': Evaluating the object store's key path did not yield a value.
, there is a good chance you forgot to include the actual object property that is mapped to thekey
.- For example you might have accidentally used something like
myTable.put({propA: valA}, keyVal)
when you needed to usemyTable.put({key: keyVal, propA: valA})
- See
Table.put()
docs for details
- For example you might have accidentally used something like