db.test.aggregate([
{ $unwind: "$stats" },
{
$group: {
_id:"$stats.year",
number:{$sum:"$stats.number"}
}
},
{
$group: {
_id: 0,
stats:{ $push: {year:"$_id",number:"$number"}}
}
},
{
$project:{stats:1,_id:0}
} ])