MongoDB opposite of $addToSet

前端 未结 1 1947
北荒
北荒 2021-02-01 12:28

I\'m aware of the $addToSet method for MongoDB, but I can\'t find a "remove" equivalent anywhere in the docs.

What\'s the best way to achieve this? Trying to ac

1条回答
  •  伪装坚强ぢ
    2021-02-01 12:55

    I think you are looking for $pull, which "removes all instances of a value from an existing array".

    db.collection.update(
      {name: 'object1'}, 
      {$pull: { tags: 'dah'}});
    

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