couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <rnew...@apache.org>
Subject Re: Equivalent of "select in, order by"
Date Fri, 13 Apr 2012 16:01:23 GMT
Firstly, there's often not a translation as CouchDB is not a
relational database. In this case, you can get much of the way;

emit([doc.group, doc.date], null);

then query with ?startkey=["group1"]&endkey=["group1",{}]. This
selects all rows where doc.group equals "group1", in date order as
["group1"] is equal or lower than any possible two element array where
the first element equals "group1" and ["group1",{}] is greater than
any two element array where the second element is any string or number
(as objects sort higher).

B.

On 13 April 2012 16:02, Pankaj Jangid <pankaj.jangid@gmail.com> wrote:
> Hi,
>
> I have documents with fields 'date' and 'group'. And this is my view:
>
> byDateGroup: {
>  map: function(doc) {
>    if (doc.date && doc.group) {
>      emit([doc.date, doc.group], null);
>    }
>  }
> }
>
> What would be the equivalent query of this:
>
> select * from docs where group in ("group1", "group2") order by date desc
>
>
> --
>
> Thanks and regards
>
> Pankaj

Mime
View raw message