Created
June 7, 2011 05:35
-
-
Save xjamundx/1011739 to your computer and use it in GitHub Desktop.
map reduce example
This file contains 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
// groups users by type | |
var map = function() { | |
emit(this.type, 1) | |
} | |
var reduce = function(key, values) { | |
var result = 0 | |
values.forEach(function(value) { | |
result += value | |
}) | |
return result | |
} | |
var options = {out:{inline:1}} | |
db.users.mapReduce(map, reduce, options) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment