這是非常簡單的實現,但可能有一些問題,我的語法在這裏:流星:更新多個配置文件值
Template.userProfilePage.events({
'submit #profile-page': function(event, template) {
event.preventDefault();
var name = template.find('#fullName').value,
address = template.find('#address').value,
company = template.find('#company').value,
otherField = template.find('#other').value;
alert(name);
Meteor.users.update(
{ _id:Meteor.user()._id },
{
$set: {
"profile.name":name,
"profile.address":address,
"profile.company":company,
"profile.other":other
}
},
{ upsert: true },
{ multi: true }
);
return false;
}
});
模板包含普通的HTML頁面。它始終引發錯誤:
RangeError: Maximum call stack size exceeded.
仍然收到相同的錯誤。我將如何檢查「允許」和「拒絕」? – 2014-09-04 19:15:11
還有一件事,很少的值可能是'insert'而不是'update'。這就是爲什麼我在我的代碼中有'{懊惱:真'}。 – 2014-09-04 19:16:50
Upsert僅適用於整個文檔,而不適用於單個字段;請參閱http://docs.meteor.com/#upsert。你確定'name','address'等都是有效的嗎?你是否像我在我的文章中描述的那樣解決了這些爭論? – 2014-09-04 19:22:52