Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I am assuming you run Meteor on Linux or Mac. If this is not the case, the code might not work.</p> <p>the most obvious reason is that the mongo database does not contain any <code>posts</code> documents. What is the output of:</p> <pre><code>$ mongo &gt; use autana_dev &gt; db.posts.find({}).count() </code></pre> <p>If the output is not <code>null</code> or <code>0</code> you might need to connect with a username and password.</p> <pre><code>export MONGO_URL="mongodb://user:password@localhost:27017/autana_dev </code></pre> <p>if this does not help, I'd try adding a bit of logging to find out if posts are not sent or not received:</p> <pre><code>Meteor.publish('posts', function() { console.log("returning " + Posts.find({}).count() + " posts"); return Posts.find(); }); </code></pre> <p>and if the number is greater than <code>0</code> on the client</p> <pre><code>var postsHandle = Meteor.subscribe('posts'); Template.main.posts = function() { if( postsHanlde.ready() ){ console.log("I have " + Posts.find({}).count() + " posts on the client"); return Posts.find(); } }; </code></pre> <p>the condition <code>if( postsHanlde.ready() )</code> ensures you do not try to show the posts before they have arrived.</p> <p>If you have documents in your mongodb but nothing gets selected in Meteor, maybe your mongodb is not working correctly. </p> <p>It is fairly easy to check that by replacing the mongodb with an online solution. Create a free account on <a href="https://mongolab.com" rel="nofollow">mongolab</a> and change your MONGO_URL to the one given by the mongolab console. Insert some posts there and test again.</p> <p>If you still do not get any documents, then ...</p> <p>That is all I can think of from your input. Hope it helped.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload