when I call
db.collection.remove({\'condition\':\'some condition\'});
This one line will delete all the matching condition documents.
justOne
An optional boolean value. To limit the deletion to just one document, set to
true
. Omit to use the default value offalse
and delete all documents matching the deletion criteria.
You can set the justOne
to true
, in order to do it.
Before MongoDB version 2.6:
db.collection.remove(
,
)
MongoDB version 2.6 or later:
db.collection.remove(
,
{
justOne: ,
writeConcern:
}
)
Like this: db.collection.remove({"condition": "some condition"}, {justOne: true});
.