Skip to content

Instantly share code, notes, and snippets.

@ntanya
Created Jun 26, 2012
Embed
What would you like to do?
Map Reduce
coll.mapReduce(
//map
function(){
emit(this.tag, {tag_date: this.tag_date, count:this.count});
},
// reduce
function(key, values){
var obj = {value: []};
for(var i in values){
obj.value.push({tag_date:values[i].tag_date, count:values[i].count});
}
return obj;
},
{out:{inline:1}},
function(error, results, stats)
{
if(error) callback(error);
else{
//print(results);
callback(null,results);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment