mongodb aggregate show only one field code example
Example 1: mongodb aggregate remove field
{ $project: { "<field1>": 0, "<field2>": 0, ... } } // Return all but the specified fields
Example 2: mongodb aggregate over nested fields
> db.demo99.aggregate([ { $project: { Count: { $objectToArray: "$Details" } } }, { $unwind: "$Count" }, { $group: { _id: "$Count.k", count: { $sum: "$Count.v.Number"} } } ])