Created
June 1, 2014 08:26
-
-
Save ellman/9b9eee8a1a50706cb18d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map = function() { | |
emit(this.suit,{count:1}); | |
} | |
reduce = function(key, values) { | |
var total = 0; | |
for ( var i=0; i<values.length; i++ ) | |
total += values[i].count; | |
return { count : total }; | |
} | |
result = db.runCommand({ | |
"mapreduce" : "cards", | |
"map" : map, | |
"reduce" : reduce, | |
"out" : "suit_count" | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment