couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <N.Breun...@vpro.nl>
Subject Re: MultiKey sorting in views
Date Tue, 13 Apr 2010 15:11:43 GMT
Pavan Kumar wrote:

>   I have documents with author and submitted time ( utc value of date )
> fields . Now i need to sort descending ( i.e latest first ) on time and
> filter by author in a view.
>
> I tried a few things like given below but they don't work. My "view"
> knowledge needs lot of catching up.. Any pointers would help..
>
> 1) Filters by author but doesn't sort by time
>
> startkey: [ author , 0 ]
> endkey : [ author, now ]
> descending : true
>
> Map:
> emit([doc.author,doc.submit_at],doc )

What is the format of your submit_at field? If you use a format that
alfabetically sorts like it would do if you sorted chronologically, then
this would work, right? I use something like that myself using
timestamps in RFC 3339 format ("Date and Time on the Internet:
Timestamps") [0] which look like this:

        2010-04-13T17:00:00+01:00

        (year-month-dayThours:minutes:seconds and optional offset)

The view keys will automatically be sorted alfabetically, but for RFC
3339 timestamps this will also be chronologically. I guess things like
UNIX timestamps stored as a JSON number would also work, but they don't
score as high on the human readability scale.

Nils Breunese.

[0] http://www.ietf.org/rfc/rfc3339.txt

De informatie vervat in deze  e-mail en meegezonden bijlagen is uitsluitend bedoeld voor gebruik
door de geadresseerde en kan vertrouwelijke informatie bevatten. Openbaarmaking, vermenigvuldiging,
verspreiding en/of verstrekking van deze informatie aan derden is voorbehouden aan geadresseerde.
De VPRO staat niet in voor de juiste en volledige overbrenging van de inhoud van een verzonden
e-mail, noch voor tijdige ontvangst daarvan.

Mime
View raw message