What is the best way to delete all documents in a collection using the Payload API?
Using Mongoose we can simply use deleteMany() - but the Payload API is "forcing" the definition of a 'where' clause - which can't be empty otherwise no document is deleted:
await payload.delete({
collection: "users",
where: { }
});
Thanks in advance!
How can we delete all documents from a collection using the Payload API?
Could you say: where: { id: { exists: true } }
As simple as that! I am used to use '$exists' and didn't think of 'exist' - thanks lot!
Star
Discord
online
Get dedicated engineering support directly from the Payload team..