when I call
db.collection.remove({'condition':'some condition'});
This one line will delete all the matching condition documents.
What If I want to remove only one of any or n-th matching condition?
You need to perform two separate queries for this
take only one item from the matching filters
var item = db.collection.findOne({'condition':'some condition'})
and delete the item by using the id
db.collection.remove({_id: item._id});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With