Skip to content

Instantly share code, notes, and snippets.

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 kylemclaren/2390885428d8a675200af35ec0572156 to your computer and use it in GitHub Desktop.
Save kylemclaren/2390885428d8a675200af35ec0572156 to your computer and use it in GitHub Desktop.
mongodb find duplicate field values
m = function () {
emit(this.my_field, 1);
}
r = function (k, vals) {
return Array.sum(vals);
}
res = db.MyCollection.mapReduce(m,r, { out : "my_output" });
db[res.result].find({value: {$gt: 1}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment