I am new in node and MongoDB.
I am trying to query a model with an array.
The array looks like this
var grArr = [ '5aabc39a3d88101e4b52c861', '5ac3a1fe83d45353bc6a995c' ]
And the query is
Group.find().where({ _id: { $in: grArr }}).exec(function(err,gdoc){
if(err)
{
callback({err:err,message:"Error looking up company"});
}
else
{
console.log(gdoc.companies); //Gives undefined
callback(null,gdoc.companies);
}
});
The query returns undefined.
Any help is highly appreciated.
gdocis an array you either need to loop over thegdocand console the values or consolegdoc[0].companies