流星连接

问题描述 投票:1回答:1

我正在尝试将我的应用程序与mongodb连接。使用静态数组数据添加帖子可以正常工作。

问题:现在{{post}}下没有显示任何内容。如果我检查我的数据库,则已插入数据。

数据库插入+代码:

db.calposts.insert({ post: "Hello world!", createdAt: new Date() });
WriteResult({ "nInserted" : 1 })

{{#each calposts}}
  {{> posts}}
{{/each}}

<template name="posts">
<div class="panel-post" id="post-draggable">
    <span>{{post}}</span>
</div>
</template>

if (Meteor.isClient) {
  Template.calendar.helpers({
    calposts: function () {
     return CalPosts.find({});
    }
  });
}
mongodb meteor
1个回答
0
投票

您是否向客户发布了calpost集合?如果没有,在某个地方的服务器文件夹中你需要使用Meteor.publish()然后在客户端,运行Meteor.subscribe()来订阅该出版物。

有关发布和订阅的更多信息,请访问meteor.com上的此页面:

https://www.meteor.com/tutorials/blaze/publish-and-subscribe

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.