【发布时间】:2015-08-11 17:23:57
【问题描述】:
我有一件大事 - 我过去几周一直在开发的流星应用程序终于上线了。但是,为了更新,我需要在我的用户个人资料中添加一个字段。
我认为使用以下代码将方法围起来会起作用:
updateUsrs_ResetHelps: function(){
if(Meteor.users.update({}, {
$set: {
'profile.helps': []
}
}))
console.log("All users profile updated : helps reset");
else
throw new Meteor.Error(500, 'Error 500: updateUsrs_ResetHelps',
'the update couldn\'t be performed');
}
问题是我的用户拥有经典的 Meteor.accounts 文档,其中包含电子邮件、_id、服务、个人资料等……但是,在个人资料中,他们没有 .helps 字段。我需要创建它。
对于未来的用户,我已经修改了帐户创建功能,在他们注册时添加此字段,但对于我已经注册的 200 个用户,我确实需要一个解决方案。
编辑:可能是因为更新中的选择器?一个简单的 {} 选择器是否可以一次更新集合的所有用户/文档?
【问题讨论】:
标签: javascript mongodb meteor meteor-accounts