Skip to content

Instantly share code, notes, and snippets.

@Deeptiman
Created November 7, 2021 15:58
Show Gist options
  • Save Deeptiman/ee0e72ca0aeaa3bdbe524face740b293 to your computer and use it in GitHub Desktop.
Save Deeptiman/ee0e72ca0aeaa3bdbe524face740b293 to your computer and use it in GitHub Desktop.
db.movies.mapReduce(
// map
function(){
emit(1,this.imdb.votes);
},
// reduce
function(key,vals){
var count = 0;
vals.forEach(function(v) {
count +=v;
});
return count;
},
{
// query
query: {
"imdb.rating": {
"$lt": 7.5
}
},
// output
out: "vote_count"
}
).find();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment