couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Davis" <>
Subject Re: select where
Date Sun, 28 Dec 2008 21:15:59 GMT
Behold the power of slices!

    if( emit(, 1);

All docs that have Tolkien as an author:"Tolkien"

Obviously, s/Tolkien/Rowling/ for books by Rowling.

The more important part is this though, say you wanted all books with
authors alphabetically from Rowling to Tolkein:"Rowling"&andkey="Tolkien"

And remember, you can emit arbitrary JSON. There's a defined sort
order over the entire range of JSON. See the View collation wiki page.

Paul Davis

On Sun, Dec 28, 2008 at 4:06 PM, Bernd Eickhoff <> wrote:
> Hello,
> I am trying to get to grips with Couchdb. Though it looks very interesting,
> I just dont understand how to query Couchdb for an abitrary value, as is
> possible with sql. Imagine I had a number of very simple documents, like:
> {"_id":"b1","_rev":"3573740128", "book":"Potter","author":"Rowling"}
> and I wanted to find all books written by Mr Tolkien?
> I could create a view like:
> function(doc) { if ( == "Tolkien") emit(null, doc); }
> and then query:
> Is there any way to pass "Tolkien" as a variable to the view, or do I have
> to create a new view, every time I want to query for another keyword?
> Thanks
> Bernd

View raw message