2011/6/7 Torstein Krause Johansen <[email protected]>: > 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 > http://guide.couchdb.org/draft/views.html#example/3 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 http://stackoverflow.com/questions/5637412/getting-a-list-of-documents-with-a-maximum-field-value-from-couchdb-view/5654154#5654154 I hope to be corrected if I am wrong. Marcello
