Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 69521 invoked from network); 13 May 2008 22:32:12 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 May 2008 22:32:12 -0000 Received: (qmail 27678 invoked by uid 500); 13 May 2008 22:32:13 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 27651 invoked by uid 500); 13 May 2008 22:32:13 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 27639 invoked by uid 99); 13 May 2008 22:32:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 May 2008 15:32:13 -0700 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 jchris@gmail.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; Tue, 13 May 2008 22:31:25 +0000 Received: by fg-out-1718.google.com with SMTP id l26so2449472fgb.26 for ; Tue, 13 May 2008 15:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; bh=rpcEWjZWtMHD0GtRB9aIuTo9+afUhAP2NU9AFwSa1tQ=; b=hh3Si5HerkDK8Ga08gjmv0CvI2BpD23pJSTUDzcsLFuycwFBNlEMEyBIdMRvQQarTW/AQfU1vbkUaxB5cgpAmdFnj+s0RQKpI0XSf+ttxtsReL70UbYj336YlLURlO+B7uIjMPq6NOJNN9z2drSdKsqtIwHPZ/kx0Nh1dyM9DSo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:sender:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=jpyaYKA5Tm5He8HJRW7XJF9vdzQi7v1oKs942JAzCvBSTFpoyynM7kNgFPr+fOVBL/cU/9dJVyBAxOCjhp930Db3yk7GfQ91lPF90pcIJf2Bpw0Xby/IbVO4GO1GsflUYloP6obzzrRAqQ4J/gBgMYqqSNQKRW9QWpMX2VQYe6s= Received: by 10.86.66.11 with SMTP id o11mr569524fga.43.1210717896830; Tue, 13 May 2008 15:31:36 -0700 (PDT) Received: by 10.86.57.13 with HTTP; Tue, 13 May 2008 15:31:36 -0700 (PDT) Message-ID: Date: Tue, 13 May 2008 15:31:36 -0700 From: "Chris Anderson" Sender: jchris@gmail.com To: couchdb-user@incubator.apache.org Subject: Re: mapping on a key that doesn't exist In-Reply-To: <5BC50A6D-FB6F-4F48-ABEE-B3904C51F5C4@apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5BC50A6D-FB6F-4F48-ABEE-B3904C51F5C4@apache.org> X-Google-Sender-Auth: c500abc53b6c857a X-Virus-Checked: Checked by ClamAV on apache.org On Tue, May 13, 2008 at 3:04 PM, Jan Lehnardt wrote: > > On May 13, 2008, at 23:19, Bob Briski wrote: > >> I've found that I can't create a view with a key that includes a document >> key that doesn't exist in all documents. You could try this simplification as a way to create a default value in the case of undefined: function(doc) { if(doc.type=="Performance") { map([doc.product_id, (doc.tracking_code||null), doc.date], doc); } } The use of || as a guard statement in this way ought to work just fine. You can use anything you want instead of null as the default. -- Chris Anderson http://jchris.mfdz.com