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 <[email protected]> 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