Skip to content

Instantly share code, notes, and snippets.

@ntanya
Created June 26, 2012 20:05
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 ntanya/2998537 to your computer and use it in GitHub Desktop.
Save ntanya/2998537 to your computer and use it in GitHub Desktop.
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