incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Metson <simonmet...@googlemail.com>
Subject Re: is there a way to pass a request parameter to a view ?
Date Wed, 23 Sep 2009 12:40:07 GMT
Hi
	CouchDB takes care of the view slicing for you (see http://wiki.apache.org/couchdb/HTTP_view_API

. You'd write a view that emits some key:values, and then do the query  
you describe (?key=foo) to return only the values with key = foo. You  
can also do startkey=foo and endkey=bar to get a slice of the view  
(e.g. look for continuous data in a range). You don't need to worry  
about this in writing your view, since the view is generated for all  
keys.
Cheers
Simon

On 23 Sep 2009, at 04:37, go canal wrote:

> Hello,
> use case:
>  - change the value of a field of documents
>
> question:
>  is there a way to pass a request parameter to the view ?
>
> I would imagine some like this:
>  /db/view?key=value
> then in the view function (doc) {
>   if (doc match some criteria)
>     doc.Type = value;
> }
> in the reduce function, I can then return the # of changed  
> documents....
>
> But the view function only accepts one argument 'doc'.
>
> Do I have to get a list, then get each document, then put ? does not  
> seem to be efficient.
>
> rgds,
> canal
>
>
>


Mime
View raw message