I have a test app based on the meteor leaderboard example which works but when I create my own app, I can't display data and the queries don't work. If I run meteor mongo in a terminal window I can see that there is data being inserted.
db.games.find();
displays all the games.
db.games.remove();
deletes all the games but neither work inside my meteor app.
Nothing in this app works except the inserts.
if (Games.find().count() === 0)
always returns zero.
Here is my main.js file.
var court = 1;
var currentDate = new Date;
var gameDate = new Date("2014-10-19");
var gameTime = new Date("21:15");
var MinutesSinceMidnightNow = (new Date() - new Date().setHours(0,0,0,0)) / 6000;
var MinutesSinceMidnightGameTime = (new Date().setHours(21,15,0,0) - new Date().setHours(0,0,0,0)) / 6000;
Games = new Meteor.Collection("games");
if (Meteor.isClient) {
Template.game.helpers({
games: function () {
return Games.find({});
} // players func
}); //template helpers
Meteor.startup(function () {
if (Games.find().count() === 0) {
Games.insert({
"court_id": court,
"game_date": gameDate,
"court_name": 'Court 1',
"game_time" : gameTime,
"team_a": "bulldogs",
"team_b": "sea eagles",
"team_a_score": 0,
"team_b_score": 0,
"game_duration": 75,
"game_half": 0,
"game_quarter": 15,
"quarter_time": 3,
"half_time": 5,
"game_minutes": MinutesSinceMidnightGameTime
});
}
});
} // isClient
if (Meteor.isServer) {
Meteor.startup(function () {
Games.remove();
});
}
Here is my HTML file.
<head>
<meta name="viewport" content="width=device-width, user-scalable=no">
</head>
<body>
<div class="outer">
{{> scoresheet}}
</div>
</body>
<template name="scoresheet">
<div class="scoresheet">
{{#each games}}
{{> game}}
{{/each}}
</div>
</template>
<template name="game">
<div class="game">
<h1>"Hello"</h1>
<span class="name">{{game_time}}</span>
<span class="name">{{court_name}}</span>
<span class="name">{{team_a}}</span>
<span class="name">{{team_b}}</span>
<span class="score">{{team_a_score}}</span>
<span class="score">{{team_b_score}}</span>
</div>
</template>