I have this collection...
> db.banks.find().pretty() { "_id" : ObjectId("54f37cbb44aec3b01b7db8f4"), "name" : "A", "branches" : [ { "branch_id" : 8561, "name" : "X", }, { "branch_id" : 8576, "name" : "Y", } ] } { "_id" : ObjectId("54f37cbb44aec3b01b7db8f5"), "name" : "B", "branches" : [ { "branch_id" : 3238, "name" : "Z", } ] } with this command :
db.banks.aggregate({$project{"branches.name":1,"_id":0}}); get this result :
{ "branches" : { { "name" : "X" }, { "name" : "Y" } } } { "branches" : { { "name" : "Z" } } } but; how I get this result? (In fact, one object and without "branches".)
{{"name" : "X"}, {"name" : "Y"}, {"name" : "Z"}} very thanks...