couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcello Nuccio <>
Subject Re: Complex queries & results
Date Tue, 07 Jun 2011 06:50:20 GMT
2011/6/7 Torstein Krause Johansen <>:
> I'm still puzzled, though. When reading up on reduces, I got put off doing
> anything fancy in the reduce function as the guide on
> states:
> "A common mistake new CouchDB users make is attempting to construct complex
> aggregate values with a reduce function. Full reductions should result in a
> scalar value, like 5, and not, for instance, a JSON hash with a set of
> unique keys and the count of each."
> And from my understanding, this is exactly what I want to do here, but
> perhaps I'm misunderstanding the author's meaning here?

In my experience it is not a problem for a reduce function to return an hash.

The strict requirement for reduce functions, is to actually reduce the
data it get passed to a small constant size value, be it a scalar or
an object.

You can look at this example for an idea of what I mean

I hope to be corrected if I am wrong.


View raw message