Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 6306 invoked from network); 2 Sep 2009 19:56:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 2 Sep 2009 19:56:02 -0000 Received: (qmail 96234 invoked by uid 500); 2 Sep 2009 19:56:01 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 96163 invoked by uid 500); 2 Sep 2009 19:56:01 -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 96153 invoked by uid 99); 2 Sep 2009 19:56:01 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 19:56:01 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [83.97.50.139] (HELO jan.prima.de) (83.97.50.139) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Sep 2009 19:55:52 +0000 Received: from [192.168.2.101] (f053034026.adsl.alicedsl.de [::ffff:78.53.34.26]) (AUTH: LOGIN jan, TLS: TLSv1/SSLv3,128bits,AES128-SHA) by jan.prima.de with esmtp; Wed, 02 Sep 2009 19:55:29 +0000 Content-Type: text/plain; charset=us-ascii; format=flowed; delsp=yes Mime-Version: 1.0 (Apple Message framework v1075.2) Subject: Re: View to find someone in a list in a document From: Jan Lehnardt In-Reply-To: <9BE6119F-6D55-4293-B209-9D23F7A33484@googlemail.com> Date: Wed, 2 Sep 2009 21:54:56 +0200 Content-Transfer-Encoding: 7bit Message-Id: <2A5814D7-3742-4FED-A451-31576904FFB3@apache.org> References: <51d0803c0909020925s75bdc063gd108f8c5618ca38c@mail.gmail.com> <9BE6119F-6D55-4293-B209-9D23F7A33484@googlemail.com> To: user@couchdb.apache.org X-Mailer: Apple Mail (2.1075.2) X-Virus-Checked: Checked by ClamAV on apache.org Style police! On 2 Sep 2009, at 19:00, Simon Metson wrote: > Hi, > Do you mean you want to emit each user as a key? Something like: > > function(doc) { for (v in doc.users) { emit(doc.users[v], doc); } is better written as 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. better yet: 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. otherwise, excellent advice! :) Cheers Jan -- > > as a map would do that. > Cheers > Simon > > On 2 Sep 2009, at 17:25, Jehan Bihin wrote: > >> Hi all, >> >> (sorry for my english) >> I have a document having a list of persons : >> >> ... >> "users":{"membre-joouul_hotmail.com":["createur"],"membre- >> killan_daaboo.net >> ":["moderateur"]} >> ... >> >> Each persons have some roles. >> My key is the membre like 'membre-joouul_hotmail.com' >> And i want to list all document having my key present in the users >> list. >> >> Is it possible and correct to have it ? >> Can you guide me ? After reading here and the site I found nothing >> talking >> on that. >> >> Thanks in advance, >> >> Jehan >