Reputation: 1385
I am using the Cloudant-Node-SDK and I want to bulk delete some documents. How can I do that?
Upvotes: 2
Views: 385
Reputation: 1385
The postBulkDocs
function allows to insert, update or delete multiple documents with one call.
To delete, call it with a _deleted
flag in each document.
For example, if you have these three docs (you only need their _id
and _rev
to delete):
var docs = [{
_id: '0007241142412418284',
_rev: '2-4567766',
_deleted: true
},
{
_id: '000459458904590453',
_rev: '3-59695945',
_deleted: true
},
{
_id: '0004590650650678',
_rev: '2-796865867967',
_deleted: true
}]
..then as long as they each have a _deleted:true
flag in the body, then they will be deleted when you call the postBulkDocs function:
await service.postBulkDocs({
db: 'mydb',
bulkDocs: {"docs":docs}
})
There are more examples in the API documentation.
Upvotes: 4