Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 78637 invoked from network); 23 Sep 2009 12:40:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Sep 2009 12:40:43 -0000 Received: (qmail 75095 invoked by uid 500); 23 Sep 2009 12:40:41 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 75022 invoked by uid 500); 23 Sep 2009 12:40:41 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 75011 invoked by uid 99); 23 Sep 2009 12:40:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2009 12:40:41 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of simonmetson@googlemail.com designates 209.85.221.179 as permitted sender) Received: from [209.85.221.179] (HELO mail-qy0-f179.google.com) (209.85.221.179) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Sep 2009 12:40:31 +0000 Received: by qyk9 with SMTP id 9so508866qyk.30 for ; Wed, 23 Sep 2009 05:40:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :in-reply-to:content-type:content-transfer-encoding:mime-version :subject:date:references:x-mailer; bh=w+Ei0Thwk1xMGg9fK+7fIoBdLTvjHwygSJR4SeyThWQ=; b=FbD/mEpY7LbP//AwrxftLZ9HpEt13DmYRmzwcRX6W6W6Vp9poyNdEIvEBRrpo51WDb 4g9Fln8YzJ2QFytyGRkuK5y5/2i71BJ0JU3pb9f5onSyUwFp42XErW7XNDhPeDossPbO m2sM5ROisNUJPmwEmhrQ6A4KXONK9DEx4XV94= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type :content-transfer-encoding:mime-version:subject:date:references :x-mailer; b=kx0pzO5zz2UpDWcUFfjtref2jgexhgfElj4URgz/OmmD2vOgvD87NA8V3mAlLNtGWq kQ0zWOmet7Hu8NuEQOP2k+4knK0eDwIkxYik/Mk2Y4/w06wbIjZmt+yfX0aTapnn3OIJ Yjsx5AL5NtV/Pd/ArPJszOoOQAvc2fwqyIvoE= Received: by 10.224.32.204 with SMTP id e12mr1789937qad.256.1253709610513; Wed, 23 Sep 2009 05:40:10 -0700 (PDT) Received: from ?192.168.0.107? (c-24-1-124-224.hsd1.il.comcast.net [24.1.124.224]) by mx.google.com with ESMTPS id 7sm120555qwb.54.2009.09.23.05.40.08 (version=SSLv3 cipher=RC4-MD5); Wed, 23 Sep 2009 05:40:09 -0700 (PDT) Message-Id: <9797E48A-A570-42BF-B6CE-1706290E9B2D@googlemail.com> From: Simon Metson To: user@couchdb.apache.org In-Reply-To: <703899.67009.qm@web45310.mail.sp1.yahoo.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: is there a way to pass a request parameter to a view ? Date: Wed, 23 Sep 2009 07:40:07 -0500 References: <703899.67009.qm@web45310.mail.sp1.yahoo.com> X-Mailer: Apple Mail (2.936) X-Virus-Checked: Checked by ClamAV on apache.org 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 > > >