我想檢查其他'集'是否有我想要添加的值。如果另一組具有該值,則將其從該組中移除並將其添加到新組。 { "_id": "5a052785aa06c22429717bad", "word": "wordtest5", "__v": 0, "pronunciations": [ { "pronunciation": "wordtest1", "_id": "5a052785aa06c22429717bae", "likes": [ "remove_this", "5a0508cfcf4f6620786a3cb1" ], "rating": 1 }, { "pronunciation": "wordtest5", "_id": "5a0674c1053ae929db3a576c", "likes": [], "rating": 1 }, { "pronunciation": "testing5", "_id": "5a06770346be3d2ac6f31561", "likes": [ "remove_this", "5a0508cfcf4f6620786a3cb1", ], "rating": 1 } ] }
我想刪除每個'likes'數組中的所有'remove_this'字符串。
嗨,我發佈了一個例子,並嘗試了'Word.findOneAndUpdate({word},{$ pull:{'pronunciations':{'likes':userId}}},{multi:true})'但不能讓它去除元素。 – earthyearth