Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 13038 invoked from network); 2 Sep 2009 20:18:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Sep 2009 20:18:47 -0000 Received: (qmail 14842 invoked by uid 500); 2 Sep 2009 20:18:46 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 14798 invoked by uid 500); 2 Sep 2009 20:18:46 -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 14788 invoked by uid 99); 2 Sep 2009 20:18:46 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 20:18:46 +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 72.14.220.155 as permitted sender) Received: from [72.14.220.155] (HELO fg-out-1718.google.com) (72.14.220.155) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 20:18:36 +0000 Received: by fg-out-1718.google.com with SMTP id d23so1154023fga.5 for ; Wed, 02 Sep 2009 13:18:14 -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=UTf4eBuafs/IEKw+pfjUzv3xi7XIKB5mChtEWhelxU8=; b=O4fSf7b6sf8e1oS7JRsgtOl0W2+pwZChVefbdxIlDOd0ZhN5AOAlAqBkPPfsk2obro bhxiravLOs6b6UuI3fH8WOe871gIP04iz9TKav6H6E3YGQYLCr/ZaZTkb8qpBBmflDQt TRhUjxMYHDpBIxxXhqMSFeBgXM2A/PRF4Qc6Y= 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=AXajnAb6s6D3pUM2kckBuZhlpjEwAHw1+xDM8dl7pX05XA9kkRh1jpzHSUB7CsmXp2 nkOH4rV3ssOB18oGNDMTUl22VbSe5c35oBCJaCrDxxRG+LOJrIguGnRAEKKYuPeSFpjk Y6vn3kuxkMINgO1iTwIiWe27y359pKn91Pokc= Received: by 10.86.13.37 with SMTP id 37mr2979815fgm.58.1251922694829; Wed, 02 Sep 2009 13:18:14 -0700 (PDT) Received: from macbookpro.lan (93-97-111-13.zone5.bethere.co.uk [93.97.111.13]) by mx.google.com with ESMTPS id 12sm1217061fgg.28.2009.09.02.13.18.13 (version=SSLv3 cipher=RC4-MD5); Wed, 02 Sep 2009 13:18:13 -0700 (PDT) Message-Id: <973D6EC3-53F0-4535-9260-C6DD60783B0F@googlemail.com> From: Simon Metson To: user@couchdb.apache.org In-Reply-To: <2A5814D7-3742-4FED-A451-31576904FFB3@apache.org> 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: View to find someone in a list in a document Date: Wed, 2 Sep 2009 21:18:12 +0100 References: <51d0803c0909020925s75bdc063gd108f8c5618ca38c@mail.gmail.com> <9BE6119F-6D55-4293-B209-9D23F7A33484@googlemail.com> <2A5814D7-3742-4FED-A451-31576904FFB3@apache.org> X-Mailer: Apple Mail (2.936) X-Virus-Checked: Checked by ClamAV on apache.org Hey Jan, > function(doc) { for (var v in doc.users) { emit(doc.users[v], doc); } > > if you leave out the `var` you create a global variable (as opposed > to a local variable in JS and that can have funky effects. What he said. > function(doc) { if(doc.users) { for (var v in doc.users) > { emit(doc.users[v], doc); }} > > protects you against errors for documents that doesn't have a > `users` property. Yeah, I was going to add that but was being lazy ;) apologies! Cheers Simon