Meteor App - 来自MongoDB的3行未在浏览器上显示

时间:2015-08-14 08:47:11

标签: mongodb meteor



这段代码有什么问题?
来自mongoDB的3行不会在浏览器上显示。

请帮忙。

My Short Meteor Code



真的找不到什么是错的。

<head>
  <title>Things to do.</title>
</head>

<body>
  <div class="container">
    <header>
      <h1>Our List</h1>
    </header>

    <ul>
      {{#each tasks}}
        {{> task}}
      {{/each}}
    </ul>
  </div>
</body>

<template name="task">
  <li>{{text}}</li>
</template>
Tasks = new Mongo.Collection("tasks");

if (Meteor.isClient) {
  // This code only runs on the client
  Template.body.helpers({
    tasks: function () {
      return Tasks.find({});
    }
  });
}
  db.tasks.find()
2015-08-14T08:27:44.644+0000 trying reconnect to 127.0.0.1:8081 (127.0.0.1) failed
2015-08-14T08:27:44.644+0000 reconnect 127.0.0.1:8081 (127.0.0.1) ok
{ "_id" : ObjectId("55cd9d2456b678da6dcaa972"), "text" : "Hello world!", "createdAt" : ISODate("2015-08-14T07:47:48.586Z") }
{ "_id" : ObjectId("55cd9e2b56b678da6dcaa975"), "text" : "Eat out!", "createdAt" : ISODate("2015-08-14T07:52:11.635Z") }
{ "_id" : ObjectId("55cd9e3e56b678da6dcaa976"), "text" : "Tour around the world.", "createdAt" : ISODate("2015-08-14T07:52:30.944Z") }

就是这样,我的代码是纯文本。

1 个答案:

答案 0 :(得分:0)

可能出错的一些事情:

  • 您的Tasks收藏可能不是published。确保您的应用中仍然安装了autopublish个包,或者在this tutorial之后发布和订阅您的收藏。
  • 您没有使用与应用程序相同的Mongodb数据库:请确保打印应用程序的MONGO_URL

在你的js文件中:

if (Meteor.isServer) {
  console.log(process.env.MONGO_URL);
}
相关问题