작동하는 유성 리더 보드 예제를 기반으로하는 테스트 앱이 있지만 내 앱을 만들 때 데이터를 표시 할 수없고 쿼리가 작동하지 않습니다. 유령 문고를 터미널 창에서 실행하면 삽입되는 데이터가 있음을 알 수 있습니다.유성 mongodb 앱에 데이터를 표시 할 수 없습니다.
db.games.find();
은 모든 게임을 표시합니다.
db.games.remove();
은 모든 게임을 삭제하지만 내 유성 앱에서는 작동하지 않습니다.
삽입물을 제외하고이 앱의 어떤 것도 작동하지 않습니다.
if (Games.find().count() === 0)
은 항상 0을 반환합니다.
여기 내 main.js 파일입니다.
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();
});
}
여기 내 HTML 파일입니다. 당신이 경쟁 조건으로 실행중인
<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>
자동 게시 패키지를 제거 했습니까? 그렇다면 일부 데이터를 구독해야 클라이언트에서 볼 수 있습니다. – richsilv
컬렉션을 비우려면 선택기'{}} - [docs # remove 참고] (http://docs.meteor.com/#remove)를 포함시켜야합니다. 그러면 Games.remove ({}))' – garrilla
그냥 나에게 발생했다. 서버 시작시'.remove()'를 놓으면 경쟁 조건이 생기게된다. 적어도 서버를 정상적인 서버로 옮겨야하지만, 아래 답변 ... – garrilla