I've got a method which updates a user field. This works but just on client, if I reload the app this field starts from 0 again.
Method:
Meteor.methods({
addPublication: function (publications) {
check(publications, Number);
Meteor.users.update(this.userId, {
$set:{
publications: publications
}
});
}
});
Controller:
Meteor.call('addPublication', Meteor.user().publications + 1);
Allow new values:
Meteor.users.allow({
update: function(userId, user) {
console.log('UPDATE USER');
return true;
}
});
Publish:
- Server
Meteor.publish('users', function() { return Meteor.users.find({}, { fields: { emails: 1, profile: 1, username: 1, publications: 1, } }); });
- Client
Meteor.subscribe('users');
Am I missing something here?