Search code examples
dexie

dexie.js difference between Table.bulkAdd() and Table.bulkPut()


The Dexie.js documentation for Table.bulkAdd()

https://dexie.org/docs/Table/Table.bulkAdd()#remarks

says: Add all given objects to the store.

The Dexie.js documentation for Table.bulkPut()

https://dexie.org/docs/Table/Table.bulkPut()#remarks

says: Add all given objects to the store.

Why are there two function if they both do the same thing, i.e. create a new records? I would have expected bulkPut() to execute updates on existing records.

Am I missing something?


Solution

  • It's a documentation issue. Will update docs. The difference between add and put is better described in the docs of Table.put() at https://dexie.org/docs/Table/Table.put() where it explains "Adds new or replaces existing object in the object store." and "If an object with the same primary key already exists, it will be replaced with the given object. If it does not exist, it will be added."