Can't add new post after added publish and subscribe?


Can’t add new post after added publish and subscribe ?


Can you please provide a few more details? Basically, publish and subscribe have nothing to do with Inserting/adding. They just decide what you can read/see from the already added posts.


I want to insert a document into a collection Posts. Should I insert into the collection with subscribed ( $meteor.collection(Nodes).subscribe(‘nodes’); ) or $meteor.collection(Posts) ?


Make sure you have create a collection called Posts in the /lib folder.
Then just do Posts.insert({title: “Post Title”, message: “Post Message”}).

Or to be more safe, split the code into Client and Server side.
On the sever side create a method like this:

    insertPost : function(newPost) {
       Posts.insert({title: newPost.title, message: newPost.message})

And on the Client side pass a new pos to that method like:

var newPost = { title: "Your post title", message: "Your message" };'insertPost', newPost);