To count things, you must use reduce functions in CouchDB. For these
purposes, I have modified some auto-generated views (retaining Hammock's
naming conventions) and added the reduce().
The problem is that in such cases for the original view to work, one must
pass "reduce=false" when querying.
Also, one needs group_level=X with more complex keys, to be able to really
count things.
The patch attached contains a proposed fix. I wanted to add the unit test
patch as well, but due my setup (Win7 in a VM, source code on a network
drive, CouchDB in another VM) nunit is not recognizing any TestFixtures.
Usage:
Spec().Reduce(false) - to get the modified view to return results, as if
it only had a map()
Spec().GroupLevel(1) - to get the reduced result set
group=true and group_level=X are mutually exclusive, and the patch
respects that.
Catch:
Query<TEntity>.All() respects the groupped nature of the modified view - I
left it intact - this may, or may not, be the right thing.
Original issue reported on code.google.com by dymonaz on 23 May 2010 at 8:04
Original issue reported on code.google.com by
dymonaz
on 23 May 2010 at 8:04Attachments: