couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Van Couvering <david.vancouver...@gmail.com>
Subject Re: Selecting part of a multi-value key
Date Mon, 22 Feb 2010 18:47:12 GMT
Great answers, all!  Note that the view Wiki and the CouchDB book talk about
using an empty value or {} to select all rows that are a match for one
element in a compound key.   IMHO key missing information.

Time permitting, I'll take a shot at the Wiki, unless someone else wants to
fix it.

David

On Mon, Feb 22, 2010 at 2:51 AM, Brian Candler <B.Candler@pobox.com> wrote:

> On Sun, Feb 21, 2010 at 02:04:57PM -0800, David Van Couvering wrote:
> > I have a view that generates a type and a date as a composite key.  This
> way
> > the results are sorted by type and then by date.
>
> That is, something like  emit([doc.type,doc.date], ...)   ?
>
> > I would like to call the view so that I get all rows that match a given
> > type, regardless of date.  I need them sorted by date.
>
> startkey=["a_type"]&endkey=["a_type",{}]
>
> (with suitable URL encoding). They will still be sorted by date, because
> they are sorted by [type,date].
>
> For reduce values for all rows with a particular type, look at
> group_level=1
>



-- 
David W. Van Couvering

http://www.linkedin.com/in/davidvc
http://davidvancouvering.blogspot.com
http://twitter.com/dcouvering

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