Skip to content

Instantly share code, notes, and snippets.

@ellman
Created June 1, 2014 08:26
Show Gist options
  • Save ellman/9b9eee8a1a50706cb18d to your computer and use it in GitHub Desktop.
Save ellman/9b9eee8a1a50706cb18d to your computer and use it in GitHub Desktop.
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