incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cesar Delgado <beett...@ymail.com>
Subject Question on selecting on reduce values
Date Fri, 30 Apr 2010 23:44:13 GMT
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
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message