MongoDb remove subdocument from document

后端 未结 2 1355
挽巷
挽巷 2021-02-07 07:03

I have a collection with a following data:

{

  \"_id\" : ObjectId(\"4e3951905e746b3805000000\"),
  \"m\" : \"hello\",
  \"r\" : [{
      \"_id\" : ObjectId(\"4e         


        
2条回答
  •  礼貌的吻别
    2021-02-07 07:16

    It's easy, you just need to use $pull operator:

    db.items.update( {}, 
    { $pull : { r : {"_id": ObjectId("4e39519d5e746bc00f000000")} } }, false, false )
    

提交回复
热议问题