couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <>
Subject RE: Need to get total rows of startkey/endkey range for paging
Date Sat, 02 Apr 2011 06:44:24 GMT
If you set the reduce function of your view to '_count' you will get the number of items. Query
with ?reduce=false if you want to get the items instead of just the count.

See for more info on built-in reduce

Van: Andrew Stuart (SuperCoders) []
Verzonden: zaterdag 2 april 2011 7:27
Onderwerp: Need to get total rows of startkey/endkey range for paging

Hey there folks

I am issuing a query to a view which uses startkey and endkey to
constrain the range of values to be retrieved from the view.  Within
this I am using skip and limit to page through the results.

The problem is that I need the count of the number of total rows, not
of the view, but of the range defined by startkey and endkey.

This is needed because I am putting the data into a paging grid, and
the paging grid needs to know the total rows so it knows how big to
make the grid and so it knows where the bottom is.

If you are interested here is a sample query:

Views do of course return the total number of items in the view, but I
need not the total items in the view but the total items in the
startkey/endkey range.

Can anyone suggest if this is possible?


View raw message