Aggregating Votes on mongodb collection
#Schema
{
_id:....
votes:[...]
}
#Aggregation
db.posts.aggregate( [
{$match: { "Votes.votedate": {$gte:thisMonth, $lt:thisMonthEnd} } },
{$unwind: "$Votes" },
{$match: { "Votes.votedate": {$gte:thisMonth, $lt:thisMonthEnd} } },
{$group: { _id: "$title", votes: {$sum:1} } },
{$sort: {"votes": -1} },
{$limit: 10}
]);