db.collection.aggregate([
{
$group: {
_id: { date: "$date" },
count: { $sum: 1 },
id_count: { $addToSet: "$id" },
name_count: { $addToSet: "$name" }
}
},
{
$project: {
_id: 0,
date: "$
_id.date",
count: 1,
id_count: { $size: "$id_count" },
name_count: { $size: "$name_count" }
}
},
{
$sort: { date: 1 }
}
])