Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 91859 invoked from network); 6 Dec 2010 19:23:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 6 Dec 2010 19:23:29 -0000 Received: (qmail 98882 invoked by uid 500); 6 Dec 2010 19:23:27 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 98810 invoked by uid 500); 6 Dec 2010 19:23:27 -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 98801 invoked by uid 99); 6 Dec 2010 19:23:27 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Dec 2010 19:23:27 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of randall.leeds@gmail.com designates 209.85.161.52 as permitted sender) Received: from [209.85.161.52] (HELO mail-fx0-f52.google.com) (209.85.161.52) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Dec 2010 19:23:20 +0000 Received: by fxm5 with SMTP id 5so9987735fxm.11 for ; Mon, 06 Dec 2010 11:23:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=ok1pXR2S/uMXIOa/g9AjnxtXx2fg9gocZNW3FjbKJkE=; b=IchLNYm3zCwRvIF1m6+IV0PXd+ohWA7lvQB6DlVGeo+4nAEG24FmB/RLfd50SxKKfW aLvZbO5y078jeWa2UIaTyyb9C4GvHsfbXJ83sL2tT/BFmZLJFf+0fZFQ67zMJJ0lp9K1 KvSzyfN/hLHjzW7lq6gMQ9g7I+ePwoC7khkIk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=XJUlOyCV/KN9QrBBq3C6pxZi79XXwkPo5m8b/K9RExaTpFXh9Gs1bX1zOwcWlOQFnF ev+zVyiCPBs7uleFjwTvtlxpApymmuuV/TuMF71pGbWOpaSyQJmx0JXJEgetVC4m5dh/ KRBqUiLFSd/MWDWKfCEL6LQR+tHBnfTZTu9w4= MIME-Version: 1.0 Received: by 10.223.87.67 with SMTP id v3mr5877570fal.130.1291663379907; Mon, 06 Dec 2010 11:22:59 -0800 (PST) Received: by 10.223.96.79 with HTTP; Mon, 6 Dec 2010 11:22:59 -0800 (PST) In-Reply-To: References: Date: Mon, 6 Dec 2010 11:22:59 -0800 Message-ID: Subject: Re: How to pass parameters to views? From: Randall Leeds To: user@couchdb.apache.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org It cannot be done due to the nature of views and the way couchdb does map-reduce. View output should be deterministic and as such cannot depend on query-time parameters. This is what allows the index to be build incrementally and the reason why a _list function runs through the whole result set every time you query it but views can be retrieved with ?stale=3Dok and aren't re-run for every request. On Mon, Dec 6, 2010 at 09:28, Wordit Ltd wrote: > Can parameters be passed to views? I know you can use them in updaters. > I hoped this would work, but it did not: > > function(doc, req) { > var myparam =3D req.query.myparam; > ... > > URL: .../view_name?myparam=3D"foo" > > > I need to pass two parameters to a for loop which is pulling data from > an array/list. > I have data stored in the array "words". > > function(doc) { > =C2=A0for (i=3D0; i < doc.words.length;i++) { > =C2=A0emit(i, doc.words[i]); > =C2=A0} > } > > This outputs ALL items in the array. I want to pass in A and B as > params to the for loop. > Can this be done, or is there another way to achieve it? > > Thanks, > > Marcus >