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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -