Skip to content

Instantly share code, notes, and snippets.

@ebarendt
Created January 16, 2013 23:16
Show Gist options
  • Save ebarendt/4551927 to your computer and use it in GitHub Desktop.
Save ebarendt/4551927 to your computer and use it in GitHub Desktop.
Map reduce trial for MongoDB
var m = function() {
emit(this.id, {opaqueId: this.opaque_id});
}
var r = function(key, values) {
var all = [];
values.forEach(function(x) {
all.push(x.opaqueId);
});
return {"opaqueId": all.join(", ")};
}
res = db.activities.mapReduce(m, r, { out: 'example' });
db.example.find().pretty();
# { "_id" : null,
# "value" : {
# "opaqueId" : "Pkkd, ckkd, Gkkd"
# }
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment