Created
March 31, 2020 16:27
-
-
Save kylemclaren/2390885428d8a675200af35ec0572156 to your computer and use it in GitHub Desktop.
mongodb find duplicate field values
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
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