I have a simpler answer for you:
db.test01.aggregate([
… { $unwind: “$votes” },
… { $sortByCount: “$votes.action” }
… ])
{ “_id” : “up”, “count” : 2 }
{ “_id” : “down”, “count” : 1 }
All the best,
– Rodrigo
I have a simpler answer for you:
db.test01.aggregate([
… { $unwind: “$votes” },
… { $sortByCount: “$votes.action” }
… ])
{ “_id” : “up”, “count” : 2 }
{ “_id” : “down”, “count” : 1 }
All the best,
– Rodrigo