Remove by _id in MongoDB console

前端 未结 11 1266
野的像风
野的像风 2020-12-22 16:14

In the MongoDB console how can I remove a record by id? Here\'s my collection :

[ 
  {
     \"_id\" : { \"$oid\" : \"4d512b45cc9374271b02ec4f\" },
     \"nam         


        
11条回答
  •  被撕碎了的回忆
    2020-12-22 17:05

    If you would like to remove by a list of IDs this works great.

    db.CollectionName.remove({
        "_id": {
            $in: [
                ObjectId("0930292929292929292929"),
                ObjectId("0920292929292929292929")
            ]
         }
    }) 
    

提交回复
热议问题