From user-return-8348-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Fri Jan 08 01:44:05 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 45754 invoked from network); 8 Jan 2010 01:44:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Jan 2010 01:44:04 -0000 Received: (qmail 17018 invoked by uid 500); 8 Jan 2010 01:44:03 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 16955 invoked by uid 500); 8 Jan 2010 01:44:03 -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 16945 invoked by uid 500); 8 Jan 2010 01:44:03 -0000 Delivered-To: apmail-incubator-couchdb-user@incubator.apache.org Received: (qmail 16942 invoked by uid 99); 8 Jan 2010 01:44:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jan 2010 01:44:03 +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 norbu09@googlemail.com designates 209.85.160.41 as permitted sender) Received: from [209.85.160.41] (HELO mail-pw0-f41.google.com) (209.85.160.41) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jan 2010 01:43:54 +0000 Received: by pwj4 with SMTP id 4so4782275pwj.20 for ; Thu, 07 Jan 2010 17:43:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=L41Igb/7E+gHqF6aWoL/+411tLFLvtfjvwJhoiVZEBU=; b=w8j90w8UTBHQlkAH7200pMsNL9hMnpp0j/sNbOTpvFIXi9js5/ZI5VmJ6G1cpX3bis G0cG8ie9xMQuz75AkB6mteHOWI6WwUB/j2nxyaqnGby8HURq8o8gLiKu0S+VIzodcB2d HOl+ooAjmPpEJWd1k6sjda0c4ElaoQTsE2BZg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Au4ExVW886S2l/Vj3/6QQ6iHrQNWdlQIehj05VgA+iKsoUb3TpIPM+8JZQ2ADq7DmX KBurqX3DbFeI/mj+MiLammftmi9365SaAgxnAZ4iv7GMYnvJlb5xWr//I9vatSjcViZv FpriFZALdyQ3zrAjYxg1HlKYPyOZkcNaWwE6Y= MIME-Version: 1.0 Received: by 10.142.59.20 with SMTP id h20mr2548916wfa.106.1262915013492; Thu, 07 Jan 2010 17:43:33 -0800 (PST) Date: Fri, 8 Jan 2010 14:43:33 +1300 Message-ID: Subject: small issue with a strange view From: lenz To: couchdb-user@incubator.apache.org Content-Type: text/plain; charset=ISO-8859-1 hi, i do stuff the clumsy way and overlook something completely obvious. my issue is that i try to map some very ugly API responses into a much saner data structure in a view. i did that in the first run simply this way: function(doc) { emit(doc.domain, {domain: doc.domain, auth: doc.PROPERTY.AUTH[0], created: doc.PROPERTY.CREATEDDATE[0], expire: doc.PROPERTY.EXPIRATIONDATE[0], ns: doc.PROPERTY.NAMESERVER, status: doc.PROPERTY.STATUS, renew: doc.PROPERTY.RENEWALMODE[0], owner: { firstname: doc.PROPERTY.OWNERCONTACT.PROPERTY.FIRSTNAME[0], lastname: doc.PROPERTY.OWNERCONTACT.PROPERTY.LASTNAME[0], company: doc.PROPERTY.OWNERCONTACT.PROPERTY.ORGANIZATION[0], street: doc.PROPERTY.OWNERCONTACT.PROPERTY.STREET[0], ..... then reality caught me and i noticed that some of the values i try to assign are actually not always there so i came up with this: ....... firstname: doc.PROPERTY.OWNERCONTACT.PROPERTY.FIRSTNAME[0] || '', lastname: doc.PROPERTY.OWNERCONTACT.PROPERTY.LASTNAME[0] || doc.PROPERTY.OWNERCONTACT.PROPERTY.NAME[0], company: doc.PROPERTY.OWNERCONTACT.PROPERTY.ORGANIZATION[0] || '', street: doc.PROPERTY.OWNERCONTACT.PROPERTY.STREET[0] || '', ....... but obviously i get still errors as for example the doc.PROPERTY.OWNERCONTACT.PROPERTY.FIRSTNAME key is not defined at all and so the array i try to get the first element of is undefined and throws an error. any sane way i can do it nicely in the emit function or do i have to write a proper parser :-) cheers lenz -- iWantMyName.com painless domain registration (finally)