Skip to content

Instantly share code, notes, and snippets.

@xjamundx
Created June 7, 2011 05:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xjamundx/1011739 to your computer and use it in GitHub Desktop.
Save xjamundx/1011739 to your computer and use it in GitHub Desktop.
map reduce example
// 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