couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J Chris Anderson <>
Subject Re: Next and previous element.
Date Fri, 18 Jun 2010 14:27:20 GMT

On Jun 18, 2010, at 5:31 AM, Francesco Mazzoli wrote:

> This may be a simple question but I couldn't find a solution by myself.
> I am coding a web application with pylons ( and couchdb,
> and I've stumbled upon a problem.
> It's a blog, and I assign a slug to every article. I get the slug from
> a get parameter in the address.
> I would like, from that article, to get the next and the previous one.
> I am using sequential uuids, and I've got this view slug_by_time that
> returns the docs slugs with the ids as keys. In this way they are
> ordered by time of creation.
> The problem is that, having one id, I can't get the previous and next
> element. My idea was simply to use the current id as startkey to find
> the next one end endkey to find the previous one, but I get weird
> results.

if you store a timestamp on the item, you can have a view by timestamp and query with limit
1 on each side of the known timestamp for next and previous.


> Any suggestions?
> Thanks in advance,
> -- Francesco

View raw message