-
-
Save ntanya/2998537 to your computer and use it in GitHub Desktop.
Map Reduce
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
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