forked from davidwen/elo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodel.js
More file actions
26 lines (21 loc) · 735 Bytes
/
model.js
File metadata and controls
26 lines (21 loc) · 735 Bytes
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
Players = new Meteor.Collection('players');
// {name: 'David', game: 'foosball', wins: 4, losses: 3, last_game: 12345...}
Games = new Meteor.Collection('games');
// {name: 'Foosball', href: 'foosball'}
Results = new Meteor.Collection('results');
// {winner: 'David', loser: 'Bob', game: foosball, timestamp: 12345, winner_change: 10, loser_change: 9}
if (Meteor.isServer) {
Meteor.publish('games', function(game) {
if (game && game.length > 0) {
return Games.find({href: game});
} else {
return Games.find({});
}
});
Meteor.publish('players', function(game) {
return Players.find({game: game});
});
Meteor.publish('results', function(game) {
return Results.find({game: game});
});
}