I have a document that's setup like this:
{
_id : '',
name : '',
friends : [
{'name' : ''},
{'name' : ''},
{'name' : ''}
]
}
I want to select just the 'friends' array and get the array of objects to iterate through. However, when I do this:
this.collection.find({'_id' : _id}, {'friends' : 1}).toArray(function(err, res) {
console.log(res);
});
This returns an array that looks like this:
[
friends : [
{'name' : ''},
{'name' : ''},
{'name' : ''}
]
]
Ideally, it would only return:
[
{'name' : ''},
{'name' : ''},
{'name' : ''}
]
Is there a way to do this?
Thank you!