我的meteor.js应用程序中存在问题,mongo更精确。当我尝试在我的Meteor.JS应用程序中进行此更新查询时它无法正常工作,它会抛出此错误:
Exception while invoking method 'deleteNotifications' MongoError: '$set' is empty. You must specify a field like so: {$mod: {<field>: ...}}
他抱怨我没有使用$ set mongo mod,但是这就是我不想使用它,你可以在下面看到我的查询(我正在使用coffeescript)。
Messages.update
_id:
$in: messagesIds
,
$push:
readByReceivers: Meteor.userId()
,
multi: true
所有需要的值都存在,最有趣的是如果我使用$ set而不是$ push,则处理查询。
当我在mongo中为meteor app尝试相同的查询时,它的工作正常:
db.messages.update({_id: {$in: ["x6PpcE829GsWarjB5"]}},{$push: {readByReceivers: "nx7XkXsmeMh6pz5n3"}},{multiple: true})
为什么流星强迫我使用$ set?
答案 0 :(得分:0)
客户端上不允许使用选项multi: true
。改为使用Meteor方法(在服务器上允许)。