I have two collection - Call them main and sub. My main collection looks like below,
{
"_id" : "xxxxx",
"subId" : "1234"
}
And my sub looks something like,
{
"_id" : "1234",
"name" : "somename"
}
And I write a query like -
Main.find({_id : { $in : ids }},function(err, results){
//Do something here
});
Now, I want my final result as,
{
"_id" : "xxxx",
"subName" : "somename"
}
How do I iterate in the documents and achieve the desired result. i am fairly new to MEAN stack. Any help would be appreciated. Thanks in advance.