You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Matthias Eck <ma...@jibbigo.com> on 2011/05/10 21:42:13 UTC

Descending dates per username

Hello,

I am having the following issue with CouchDB:

My view outputs an array key made up of a username and a timestamp:
emit([doc.user, doc.timestamp]).
I would like to use the view to get all docs for a specific user
sorted by timestamp, with the newest documents first.

Using ...?startkey=["user"]&endkey=["user",{}] works fine, but sorts
the docs in the wrong order.
Now adding &descending=true gives an empty result.

Thanks for any help,
Matthias

Re: Descending dates per username

Posted by Robert Newson <ro...@gmail.com>.
Reverse your startkey and endkey values if you use descending=true
(it's logical if you think about it).

B.

On 10 May 2011 20:42, Matthias Eck <ma...@jibbigo.com> wrote:
> Hello,
>
> I am having the following issue with CouchDB:
>
> My view outputs an array key made up of a username and a timestamp:
> emit([doc.user, doc.timestamp]).
> I would like to use the view to get all docs for a specific user
> sorted by timestamp, with the newest documents first.
>
> Using ...?startkey=["user"]&endkey=["user",{}] works fine, but sorts
> the docs in the wrong order.
> Now adding &descending=true gives an empty result.
>
> Thanks for any help,
> Matthias
>