incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sebastian Cohnen <sebastiancoh...@googlemail.com>
Subject Re: endkey doesn't obey limit parameter and always returns entries starting with offset 0
Date Sun, 12 Sep 2010 08:39:41 GMT
Hey Henrik,

this does not sound like a bug.

You need to specify a startkey, if you want proper pagination. couch streams results from
the index from startkey to endkey, but limited to the given limit parameter. if you don't
provide a startkey, couch will stream from the beginning (AFAIK) up to endkey when the limit
of results is hit (whichever comes first). this is the reason why you will always see the
first "page" in your application.

I'm not sure if there is an example in the couchdb book or in the wiki, but sofa (jchris'
blog couchapp) has pagination build in. Maybe you can have a look there (http://github.com/jchris/sofa).
Pagination is best build using startkey and limit.


Best

Sebastian

On 12.09.2010, at 09:06, Henrik Skupin wrote:

> Hi,
> 
> For my current Couch application I'm using pagination to show only 50
> results per page. To navigate back and forward the endkey vs. startkey
> parameters are used. While startkey in combination with limit is working
> fine, endkey doesn't return results for [offset(endkey)-limit,
> offset(endkey)] but for [0, limit]. This makes pagination impossible for me
> and looks like to be a bug. An example you can find here:
> 
> http://mozmill.hskupin.info/general/reports
> 
> After opening the page click 'Next' twice and check the URL of the
> 'Previous' link before clicking on it. The endkey parameter will not be
> obeyed and a click on that link causes the first page to be opened.
> 
> The code can be found at: http://github.com/whimboo/mozmill-dashboard
> 
> Is the above problem a known broken behavior and worth filing a bug?
> 
> Thanks,
> Henrik


Mime
View raw message