我有一个json对象如下:
{ "_id" : ObjectId("508806803bb97dc546e6f307"), "user_name" : "user1", "user_id" : 45645645, "likes" : [ { "event_id" : NumberLong("4578541212") },{ "event_id" : NumberLong("4578541213") } ], "dislikes" : [ ] }
我正在尝试通过 java 驱动程序删除 likes 数组中的特定事件,尝试首先在 shell 中执行此操作:
> db.users.update( {'likes.event_id' : 4578541212}, { '$unset':{'likes.event_id'
:1}})
没有运气......我怎么能做到这一点?