I've had a map/reduce view that will tell me how many of a certain name there
are in the Database. It's very simple:
Map:
function(doc) {
fileVer = doc._id + "?rev=" + doc._rev emit(doc.filename, 1);
}
Reduce:
function(key, values) { return sum(values) ;
}
Now what I want to do is be able to select by the count that is returned to me.
Basicaly I want to be able to ask the database to show me all the doc.filename
where sum(values) > arbitrary_number.
I've tried hard-coding it:
function(key, values) {
if (sum(values) > 2) { return sum(values) ;
}
}
But that gives me an error.
I'd be perfectly happy hardoding the value if needed but would love to have it
be a variable.
What subtlety am I missing here?
Thanks all,
-Cesar