Joshua's Docs - Dexie.js IndexedDB Library - Assorted Notes
Light

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.

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.
  • 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 the key.
    • For example you might have accidentally used something like myTable.put({propA: valA}, keyVal) when you needed to use myTable.put({key: keyVal, propA: valA})
    • See Table.put() docs for details
Markdown Source Last Updated:
Wed Oct 14 2020 03:52:26 GMT+0000 (Coordinated Universal Time)
Markdown Source Created:
Tue Oct 13 2020 07:11:01 GMT+0000 (Coordinated Universal Time)
© 2024 Joshua Tzucker, Built with Gatsby
Feedback