Simply use remove
the same way you use find
.
If the following line returns the records to be removed:
db.animals.find({'color':'red'})
then this will remove them:
db.animals.remove({'color':'red'})
If you already have a list of IDs to remove, you can remove with a filter on the _id
, using the $in
operator, like this:
db.animals.remove({'_id': {'$in': idsToRemove}})