Versuchen Sie den folgenden CodeRefer - https://docs.mongodb.com/manual /reference/operator/aggregation/eq/
https://docs.mongodb.com/manual/reference/operator/ Aggregation/Bedingung/
https://docs.mongodb.com/manual/reference/operator/ Zusammenfassung/Gruppe/
DB.aggregate([
{$project:
{
tag_id: '$tag_id',
unreadcount: { $cond: [ { $eq: [ '$unread', 'true' ] }, 1, 0 ] }
}},
{ $group: {
_id: '$tag_id',
unread: { $sum: '$unreadcount'},
}}
], function (err, results) {
console.log(results);
})