if (Meteor.isClient) {
Meteor.subscribe('users');
Template.hello.events({
'click #button': function () {
var userId = Meteor.userId();
Meteor.call('scored', userId, {$set: { score: 1 }});
}
});
}
if (Meteor.isServer) {
Meteor.publish('users', function() {
return Meteor.users.find();
});
Accounts.onCreateUser(function(options, user) {
user.score = 0;
if (options.profile) {
user.profile = options.profile;
}
return user;
});
Meteor.methods({
scored: function (userId, score) {
Meteor.users.update(userId, score);
}
});
}