Last active
April 8, 2018 02:02
-
-
Save nicolasembleton/10c0def71d0a25fb213d to your computer and use it in GitHub Desktop.
MongoDB Queries
This file contains hidden or 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 () { | |
if(this.Model === 1) { // business logic specific, to remove if not need (allows to filter un-wanted values / keys) | |
for(var i in this.embed) { | |
key = i; // the key to look dupes for | |
value = 1; // cnt | |
emit(key, value); | |
} | |
} | |
} | |
r = function (key, values) { | |
return Array.sum(values); | |
} | |
db.MediaPlan.mapReduce(m, r, {out: {inline: 1}}) |
This file contains hidden or 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.ID, 1); | |
} | |
r = function (k, vals) { | |
return Array.sum(vals); | |
} | |
db.Vehicle.mapReduce(m, r, {out: {inline: 1}, query: {value: {$gt: 1}}}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment