【发布时间】:2015-11-07 22:00:42
【问题描述】:
我正在尝试使用onCreateUser 更新在user.profile 中创建的firstName 字段:
Accounts.onCreateUser(function(options, user) {
user.profile = options.profile || {};
user.profile.firstName = options.firstName;
return user;
});
我也使用了允许:
Meteor.users.allow({
update: function(userId, doc, fields, modifier) {
if (fields === "profile.firstName") {
return true;
}
}
});
当我使用时:
Meteor.users.update({
_id: Meteor.userId()
}, {
$set: {
profile: "George"
}
});
它有效,但不是我需要的。
我需要更新firstName:
Meteor.users.update({
_id: Meteor.userId()
}, {
$set: {
profile.firstName: "George"
}
});
但我收到此错误:
SyntaxError: missing : after property id
我错过了什么?
【问题讨论】:
标签: javascript mongodb meteor meteor-accounts