MongoDB - Pull multiple objects from an array

后端 未结 1 922
名媛妹妹
名媛妹妹 2020-12-30 11:16

Hi I\'m trying to remove multiple objects from an array that looks like this.

{
\"_id\" : ObjectId(\"5a7da1bda21d5f3e8cf005b3\"),
\"owner\" : \"1\",
\"group_         


        
相关标签:
1条回答
  • 2020-12-30 11:39

    Use $in operator to pass the list of faculty values to remove documents from embedded array. More here

    Try

    db.groups.update(
      {"_id": ObjectId("5a7da1bda21d5f3e8cf005b3")},
      {"$pull":{"group_members":{"faculty_number":{$in:[8025,7323]}}}}
    )
    
    0 讨论(0)
提交回复
热议问题