[英]Adding a user id field into the Meteor.Users collection of Accounts package
[英]Unable to increment custom field in Meteor.users collection
我無法增加Meteor.users集合中的自定義字段。 客戶端更新一秒鍾,但服務器隨后拒絕更改。 該代碼確實可以在mongo控制台上運行:
Template.profile.events({
'click .follow': function(e) {
var followed = this.userProfile._id;
var follower = Meteor.user()._id;
Meteor.call('updateFollowers',followed,follower);
}
});
Meteor.methods({
updateFollowers: function(followed,follower)
{
alert(followed);
var affected = Meteor.users.update({ _id: followed } ,{ $inc: {followersCount: 1}});
alert(affected);
}
});
知道我可能會缺少什么嗎?
好吧,我在發布后兩秒鍾內解決了它! 只需將代碼移動到服務器端文件夾(本例中為collections文件夾)即可。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.