[英]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.