mongoose aggregate by date code example
Example: mongoose aggregate group by date
yourModel.aggregate([
{
$group: {
_id: {
$dateToString: {
format: "%Y-%m-%d",
date: "$date"
}
},
count: {
$sum: 1
}
}
},
{
$sort: {
_id: 1
}
}
])