node.js - Returning nested array from mongodb and native node driver -
i have document that's setup this:
{ _id : '', name : '', friends : [ {'name' : ''}, {'name' : ''}, {'name' : ''} ] }
i want select 'friends' array , array of objects iterate through. however, when this:
this.collection.find({'_id' : _id}, {'friends' : 1}).toarray(function(err, res) { console.log(res); });
this returns array looks this:
[ friends : [ {'name' : ''}, {'name' : ''}, {'name' : ''} ] ]
ideally, return:
[ {'name' : ''}, {'name' : ''}, {'name' : ''} ]
is there way this?
thank you!
Comments
Post a Comment