Search code examples
dexie

dexie js bulkDelete - argument keys – array or object


The dexie js documentation says about the bulk delete syntax:

https://dexie.org/docs/Table/Table.bulkDelete()

db.table.bulkDelete(keys)

I don't understand what keys means in this context? Only an array of primary keys or can also objects get passed like the following example where parent_id is an indexed property?

e.g. schema

db.version(1).stores({nodes: "++id,parent_id, name"});

and then do bulk delete like this

db.table.bulkDelete({parent_id: 3, parent_id: 4})

Solution

  • Keys are the primary key. In your case an array of numbers.

    For example:

    await db.table.bulkDelete([1,2,3]);
    

    Will delete entries with id 1,2 and 3.