#`payload.delete` only deleting 10 documents at a time

1 messages · Page 1 of 1 (latest)

silver galleon
#

I am using the following snippet to delete documents from a collection:

await payload.delete({
    collection: collectionSlug,
    where: {
      'metadata.id': {
        in: metadataIds
      }
    },
    depth: 0,
    user: user
  })

This is only deleting 10 documents per invocation. (when I call it again, it will delete the next 10 documents...) However, limit is not a valid option parameter to payload.delete as it is with payload.find. Any ideas how to delete all the documents which meet the where query? Thanks!

hallow mantleBOT
delicate reef
#

Hmm, while I agree that the 10 document limit, and the missing "limit" param is weird

#

In the meantime, you could add an endpoint to take care of this though

#

Let me know if you'd like an example

silver galleon
#

@delicate reef this code snippet is in a custom endpoint. Any suggestions for deleting all at once would be appreciated! Thanks

#

Considering using payload.find with a large limit to get all the IDs of docs to delete, and then calling payload.delete with each ID...