Remove embedded document in a nested array of documents

后端 未结 1 899
独厮守ぢ
独厮守ぢ 2020-11-29 05:27

My schema looks like this:

\"content\" : [
        {
            \"_id\" : ObjectId(\"4fc63de85b20fb72290000f8\"),
          


        
相关标签:
1条回答
  • 2020-11-29 06:14

    You are so close! Remember that your outermost "content" is an array itself. So the following 2 character change works, use content.$.assets inside the value for $pull.

    db.presentations.update(
      {'content.assets._id': ObjectId('4fc63def5b20fb722900010e')}, 
      {$pull: {'content.$.assets': {'_id': ObjectId('4fc63def5b20fb722900010e')}}}
    )
    

    Zoom ahead.

    0 讨论(0)
提交回复
热议问题