我如何在我的流星应用中编辑用户详细信息。我的代码是
Meteor.users.update({_id:this._id}, { $set:{"profile.name":pname}} )
这仅适用于列表中的第一用户。我该如何为列出的所有用户执行此操作?
我发现,更新流星用户的唯一方法是使用_id使用 Meteor.userId()
设置标准:
Meteor.users.update( { _id: Meteor.userId() }, { $set: { 'oauth.token': token }} );
我在服务器端执行此操作,因此它将阻止客户端直到Mongo的成功/失败。
问题是您是在引用不存在的东西
替换:
Meteor.users.update({_id:this._id}, { $set:{"profile.name":pname}} )
作者:
Meteor.users.update({_id:this.userId}, { $set:{"profile.name":pname}} )
或在@occasl之前使用Meteor.userid()。
刚刚发生在我身上
根据http://docs.meteor.com/#update,将" multi"选项设置为" true":
Meteor.users.update({_id:this._id}, { $set:{"profile.name":pname}}, {multi: true} )