-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
35 lines (29 loc) · 817 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
if (Meteor.isServer) {
Meteor.publish("playerData", function() {
return Players.find();
});
// Set which users can see server metrics
Facts.setUserIdFilter(function () {
return true;
});
}
if (Meteor.isClient) {
Meteor.subscribe("playerData");
// Pass query results to the "players" template
Template.players.scorers = function () {
return Players.find();
};
// Grab user input fields
Template.form.events({
'submit form' : function (event, template) {
var name = template.find("input[name=name]").value;
var score = template.find("input[name=score]").value;
// Do input validation
// Insert into database
var data = { name: name, score: score };
Players.insert(data, function(err) {
if(err) throw err;
});
}
});
}