[英]Update element from user profile in Meteor
我正在尝试使用onCreateUser
更新在user.profile
创建的firstName
字段:
Accounts.onCreateUser(function(options, user) {
user.profile = options.profile || {};
user.profile.firstName = options.firstName;
return user;
});
我也使用allow:
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:缺少:属性ID之后
我想念什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.