couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antony Blakey <>
Subject Re: dual purpose filter/count views
Date Sun, 09 Nov 2008 21:47:47 GMT

On 10/11/2008, at 8:06 AM, Sho Fukamachi wrote:

> This is probably some really simple thing that I'm missing in my  
> tired state. Can anyone give me a hint as to what it is? : )

The reduce function takes a third parameter, which is false when the  
input to the reduce function is output from your map function, and  
true when the input to the reduce function is output from previous  
invocations of the reduce function. In your case you could do  
something like this:

   reduce: function(keys, values, rereduce) { if (rereduce) return  
sum(values) else return sum(values[1]) }

When doing a re-reduce, keys will also be null.

Antony Blakey
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

On the other side, you have the customer and/or user, and they tend to  
do what we call "automating the pain." They say, "What is it we're  
doing now? How would that look if we automated it?" Whereas, what the  
design process should properly be is one of saying, "What are the  
goals we're trying to accomplish and how can we get rid of all this  
task crap?"
   -- Alan Cooper

View raw message