couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Kirchgessner <>
Subject Re: Views, lookup by a key, then sort by another one?
Date Thu, 06 Jan 2011 14:48:17 GMT
On Thu, Jan 6, 2011 at 3:26 PM, He Shiming <> wrote:

> Thanks Martin. I actually read those. The key can be a JSON array.
> However, in my situation I only wanted to sort by the date, I didn't
> really want to specify a date in the first type query. Do you have an
> example of what this complex key should look like when querying?

To sort by date you should emit( [doc.user_group, doc.updated_at], doc.type)
- however documents will still be sorted by user group first.

With such keys you query a perticular date range by providing, for instance,

You will still be able to do simple queries like : key=["developers"]

If you need to filter documents with updated_at only, another view where
updated_at is the single key is a better option.



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message