Is it possible to flatten MongoDB result query?
You can use $project & $unwind & $group of aggregation framework to get the result closer to your requirement. > db.countries.aggregate({$project:{a:’$data.country.neighbor.name’}}, {$unwind:’$a’}, {$unwind:’$a’}, {$group:{_id:’a’,res:{$addToSet:’$a’}}}) { “result” : [ { “_id” : “a”, “res” : [ “Colombia”, “Malaysia”, “Switzerland”, “Costa Rica”, “Austria” ] } ], “ok” : 1 } $unwind used twice since the name array … Read more