我试图用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({});
}
});
}
你发现'CalPosts'但你插入'db.calposts'?应该是'CalPosts.insert()' –
db.calposts.insert ..是用于添加数据的mongo shell命令。它指的是CalPosts = new Meteor.Collection('calposts'); – Flo