Remove only one document in MongoDB

后端 未结 9 2006
日久生厌
日久生厌 2021-01-12 23:42

when I call

db.collection.remove({\'condition\':\'some condition\'});

This one line will delete all the matching condition documents.

9条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-12 23:55

    db.collection.remove now has a justOne flag

    http://docs.mongodb.org/manual/reference/method/db.collection.remove/#db.collection.remove

提交回复
热议问题