Remove only one document in MongoDB

后端 未结 9 2049
日久生厌
日久生厌 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-13 00:10

    I used this and it's worked for me

    db.eventList.remove({"_id":ObjectId("5d9f3bd0c02cef7d50bb97fb")});
    

    this is working on MongoDB shell version: 3.2.17

    here eventList ===> collection

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题