Rectangle 27 0

Verify you do not have an error in your client code. With, if you do not initialize a variable you can have an error condition that will block reactive updating in your templates but continue to write fine to your console just before hand.

   somevar: function({
              if ({
              //do something

Now the somevar function gets called on render, before the returns. Therefore the variable some_session_var_set_by_a_call isn't set yet. The whole thing stops client side on the undefined error.

As you can see, I check for errors and log all the variables before inserting. Nothing errors in the console either. Is there something else I can do to check? Also, I did check the db directly per @emgee suggestion and I'm showing that the comments are being posted. Now it seems that the issues is that client code is not accessing the collection properly. Ideas?

Erick I can't see that, because I can't see your function, your render functions,helper functions or your template that you serve to the client. Since you have no errors, why don't you try a print (console.log) inside a callback within the function and see what happens. You also need to connect some sort of reactive element (either a session.get or a cursor) in the template to update it when the asynchronous function returns at a later point. The asynchronous function must modify that reactive variable to create the dependency.

Thanks for the input. I misspelled 'comments' as 'commments'.

Did that break the code then on the client? Was I right? Glad you figured it out!

It didn't error out. It just tried to return everything from the database in the 'commments' collection, but it didn't exist. Appreciate you taking the time to review this. :)

asynchronous - Meteor insert into collection appears to work, but rema...

asynchronous meteor
Rectangle 27 0

I'm not sure exactly what's wrong, but there's a few things to check here.

Meteor.publish("comments", function () {
    return Comments.find();

directs the server to publish the Collection, but doesn't actually establish the collection server side.

You should have Comments = new Meteor.Collection("comments"); available on both the client and the server. I tend to put in a file called model.js like the examples tend to do.

Second possibility, you don't have a subscribe function shown above, such as Meteor.subscribe("comments"); If you don't have a subscribe function, your client isn't going to know about it, even though it does exist in the collection.

You can test this theory by typing meteor mongo in the shell (with your Meteor app running), and db.comments.find() to see if your comments are actually in the database but not subscribed to.

I checked my code and I forgot to note that I do have the Meteor.subscribe in my model.js. I have the Comments = new Meteor.Collection("comments"); in the main page, but I also have the same for Post and Section collections and they work as expected. I did check and they are in the database. Any other idea why they might not be showing?

Meteor.subscribe(...) should be in your client code, not shared... Perhaps update the code in your question? It should be very easy to locate the bug if I could see where it is :)

My mistake (I still need my morning coffee). The Meteor.subscribe() is on the client, not the model. The Comments = new Meteor.Collection("comments"); is in the model.js file.

Meteor.subscribe("commments"); <-- extra 'm' in the code or just in the question?

asynchronous - Meteor insert into collection appears to work, but rema...

asynchronous meteor