![](/img/trans.png)
[英]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.