I woud like to aim this question mostly at @brett19 as I’ve read your blog post but if anyone else can help, that’s appreciated as well.
I would like to paginate over all docs returned by a view without filtering on a key. I have read that using doc IDs performs much better than “skip” as skip will need to read all results from the view and count to the first result. That blog post says that to use startkey_docid you need to combine it with startkey, and that startkey must be in the results. This doesn’t work if you just want to paginate over all docs in the view. Is there something like “start_docid” to do this, or is skip/limit the only way?
I have worked out a way to do this. In my paginated results, I’m using the ID from the final row as the startkey_docid for the next page. Just clicked with me that I can also use the key from the final row as the startkey for the next row.
One problem with this is that in the ViewQuery.range function (at least in the API library that I’m using - NodeJS v2.4.1) you have to specify both startkey and endkey in the range command, not just startkey. This is contrary to the documentation which seems to suggest both args are optional, so may be a bug in this API version. To get round this I make an additional query at the beginning with no ranges set but order=descending and limit=1. This gives me the last key, which I can then use in the range command to get my paginated results.
If anyone has a better/simpler way to do this (preferably something where I don’t have to specify keys at all and can just specify start ID), I would be interested.