草庐IT

subscribedRooms

全部标签

mongodb - 如何连接 MongoDB $set 中的字符串

我有一个相当复杂的MongoDB运算符,它使用where来查看多个用户以查看他们是否具有特定值,如果有,它会更改该值。我的问题是它检查的值在不同情况下可能不同,所以我的$set会要求我将字符串加在一起以获得我要更改的属性。这就是我的意思:users.update({$where:function(){returnthis.profile.chatInfo.subscribedRooms.hasOwnProperty(findChatroom._id);}},{$set:{"profile.chatInfo.subscribedRooms."+findChatroom._id:false