I have a collection where each document looks like this
{access_key:'xxxxxxxxx', keyword: "banana", count:12, request_hour:"Thu Sep 30 2010 12:00:00 GMT+0000 (UTC)"}
{access_key:'yyyyyyyyy', keyword: "apple", count:25, request_hour:"Thu Sep 30 2010 12:00:00 GMT+0000 (UTC)", }
.....
To achieve this:
SELECT keyword, sum(count) FROM keywords_counter WHERE access_key = 'xxxxxxxxx' GROUP BY keyword
I'm doing this:
db.keywords_counter.group({key : {keyword:true},
cond : {access_key: "xxxxx"},
reduce : function(obj, prev){prev.total += obj.count},
initial : {total:0}})
How do I achieve the same thing with map/reduce? [I'm a map/reduce beginner and trying to wrap my head around the concept.]