couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Zachary Zolton <zachary.zol...@gmail.com>
Subject Re: Equivalent of "select in, order by"
Date Fri, 13 Apr 2012 16:26:08 GMT
Also, getting this featured into 1.3 would eliminate the need to make a
request for each group:

https://issues.apache.org/jira/browse/COUCHDB-523

On Friday, April 13, 2012, Robert Newson wrote:

> 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<javascript:;>>
> 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
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message