【发布时间】:2016-06-12 20:16:59
【问题描述】:
此 Meteor 服务器代码尝试更新用户集合中的所有记录,但未能这样做。我该如何解决?谢谢
Meteor.startup(function() {
Meteor.users.update({}, {
$unset: {
'profile.taskInProgress': 1
}
});
});
【问题讨论】:
此 Meteor 服务器代码尝试更新用户集合中的所有记录,但未能这样做。我该如何解决?谢谢
Meteor.startup(function() {
Meteor.users.update({}, {
$unset: {
'profile.taskInProgress': 1
}
});
});
【问题讨论】:
查看 mongoDB $unset 运算符的文档:
操作员删除特定字段
如果您尝试更新正在进行中的任务的值,请改用 $set 运算符。
还要确保添加正确的选项:{multi:true}。 根据 Mongo.Collection#update 的 Meteor 文档,multi 的默认值是 flase。
【讨论】: