Create unique field in MongoDB aggregate when grouping by two fields, and use for sorting
When aggregating a collection with the following pipeline stages let ap = [{ $group: { _id: { year: { $year: '$itemDate' }, month: { $month: '$itemDate' }, }, count: { $sum: 1 }, }, }] I receive something like this...…