MongoDB has an aggregate method May 28, 2013
And I'm writing a disc golf score keeping and statistics tracking application. I wanted to see what course a particular user played the most.
db.scores.aggregate([{$match: { user: userId } }, {$group: { _id: { course: "$course", variant: "$variant", tees: "$tees" }, played: { "$sum": 1 } } }]);
It shows that in the score keeping data, I've played the Blue Tees at the Front Nine at Sedgley Woods 6 times, and the Back Nine 5 times, since last year.
[
{"_id":{"course":"50acfe3b91b5581439a05ed2","variant":"back-9","tees":"blue"},"played":5},
{"_id":{"course":"50acfe3b91b5581439a05ed2","variant":"front-9","tees":"blue"},"played":6}
]
I will be able to use this to get a whole bunch of different statistics :) I will make an announcement when that goes live, I want to put it on the web, it'll be fun. It's written on my latest of the software I'm writing in Node.js.