Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <a href="http://guide.couchdb.org/" rel="noreferrer">CouchDB Guide</a> has a good discussion of pagination, including lots of sample code, here: <a href="http://guide.couchdb.org/draft/recipes.html#pagination" rel="noreferrer">http://guide.couchdb.org/draft/recipes.html#pagination</a> Here's their algorithm:</p> <ul> <li>Request <code>rows_per_page + 1</code> rows from the view</li> <li>Display <code>rows_per_page</code> rows, store last row as <code>next_startkey</code></li> <li>As page information, keep <code>startkey</code> and <code>next_startkey</code></li> <li>Use the <code>next_*</code> values to create the next link, and use the others to create the previous link</li> </ul> <p>N.B.: The proper way to fetch pages in CouchDB is by specifying a starting key, not a starting index like you might think. But how do you know what key to start the 2nd page on? The clever solution: "Instead of requesting 10 rows for a page, you request 11 rows, but display only 10 and use the values in the 11th row as the startkey for the next page."</p> <p>If you expect to have multiple documents emit identical keys, you'll need to use <code>startdocid</code> in addition to <code>startkey</code> to paginate correctly. The reason is that <code>startkey</code> alone will no longer be sufficient to uniquely identify a row. Those parameters are useless if you don't provide a <code>startkey</code>. In fact, CouchDB will first look at the <code>startkey</code> parameter, then it will use the <code>startdocid</code> parameter to further redefine the beginning of the range if multiple potential staring rows have the same key but different document IDs. Same thing for the <code>enddocid</code>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload