Delete all records of collection

What is the recommended way to delete all records of a collection?

  1. Removing each field with entry.unset("fieldName")
  2. Iterating over all results and call entry.destroy
  3. Delete the collection? (=> How?)

Iโ€™m currently going through each result, which for quick testing seemed fine but is not really scaleable.

you can delete all the rows of a table directly from your dashboard, you have something in the top right of the window that can do that, it will ask you to write the table name to confirm that you want to delete all the rows from that table

Itโ€™s a bit cumbersome and takes 5 clicks + typing in the collection name. Which for 2 or 3 collections is really annoying with time.

Iโ€™m looking for a programmatic way to do the same.

you could try Bulk Delete:

Thanks! The BulkDeleteMany looks perfect, where can I find it under moralis/node? I donโ€™t get it under Moralis.bulkDeleteMany ? (Is it just a typescript problem :thinking: )

it may be accessible only from cloud code now

1 Like

I see, will give it a try thanks !