I've been following some Couch training, but cannot figure out how to use reduce in Fauxton. Selecting '_count' underneath the map area does nothing by itself. I have tried adding it below the map code, but I guess I need to integrate it somehow. In my example I'm trying to count how many times each tag is used in all documents. This is my view code:
function (doc, meta) {
if(doc.tags) {
for(var i in doc.tags) {
emit(doc.tags[i],1);
}
}
}
function (tag, counts) {
var sum = 0; for ( var i = 0; i < counts.length; i++) {
sum += counts[i];
};
return sum;
}