Just a basic question on the Discover Meteor tutorial. I’ve worked through the Microscope exercise but now trying to understand how I replicate in my own project.
I’m comparing the postInsert method…
var postId = Posts.insert(post);
return {
_id: postId
};
…with the two ways we insert Posts in Fixtures file.
Option#1
var telescopeId = Posts.insert({...});
...
postId: telescopeId,
Option #2
Posts.insert({});
These are all slightly different but all seem to work the same way. So my question is, what is the purpose of :
return {
_id: postId
};
…in the method? The book says “returning the resulting _id to the client (in other words, the original caller of this method) in a JavaScript object”. But if it isn’t necessary in Fixtures and I can still access those documents, why is it necessary? Specifically, is excluding this code the reason I’m having trouble returning the _id from documents when querying on other attributes?
Complete beginner to all programming so forgive the elementary question. Thanks for any help.
Brendan