Reputation: 9037
I'm trying to display the records from a mongodb collection to my meteorjs app
template
<head>
<title>simple</title>
</head>
<body>
<div class="container">
<header>
<h1>Todo List</h1>
</header>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</div>
</body>
<template name="task">
<li>{{title}}</li>
</template>
main.js
tasks_list = new Mongo.Collection('todoList');
if(Meteor.isClient){
Template.body.helpers({
tasks: function(){
return tasks_list.find();
}
});
}
if(Meteor.isServer){
Meteor.startup(function(){
// code to run on server at start up
});
}
and I'm sure I have 'todoList' collection as I check it by 'db.todoList.find()' but sadly there are no records displaying from 'todoList' collection when I tried to render it unto my meteor app, any ideas, help please?
Upvotes: 0
Views: 44
Reputation: 393
Your code seems ok. Make sure you either have the auto-publish packaged installed, or you manage the publish/subscribe correctly, so that when you run tasks_list.find() on the client, it actually finds the documents.
As a quick test, open the browser console, and type tasks_list.find().fecth() to see if the expected documents are returned.
Upvotes: 1