Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3DD9D4344 for ; Tue, 21 Jun 2011 04:42:12 +0000 (UTC) Received: (qmail 87573 invoked by uid 500); 21 Jun 2011 04:42:07 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 87355 invoked by uid 500); 21 Jun 2011 04:42:07 -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 Delivered-To: moderator for user@couchdb.apache.org Received: (qmail 62203 invoked by uid 99); 16 Jun 2011 22:02:34 -0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01CC2C71.066B52AB" Subject: How to view child arrays in couch X-MimeOLE: Produced By Microsoft Exchange V6.5 Date: Thu, 16 Jun 2011 15:01:37 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: thread-topic: How to view child arrays in couch thread-index: AcwsbwwP5eXRxznRRKSQybvG4vo5Wg== From: "Trevor Green" To: X-Virus-Checked: Checked by ClamAV on apache.org ------_=_NextPart_001_01CC2C71.066B52AB Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable =20 So what I want to do is store php objects in couch. =20 So=20 =20 Json_encode an object that may be a multi-dimensional array and store it and the view it.=20 =20 The stored data would look something like this.=20 =20 { "url": "(a url)", "status": [{ "somename": { "var1": "mystate", "var2":"mystate2" } }] } =20 So how then do map this? =20 function(doc) { emit([doc.url, doc.status, doc.status.(use the first nameas a key without explicity defining it (ex. somename) ) ], doc); } } =20 Maybe use an if(doc.status.(first value) =3D=3D "somename") to limit the set? =20 How do you create views on lists like this that contain associative arrays with arbitrary data? And how do you then access the children (var1, var2).=20 =20 Can couch not handle a document like this that is valid json but isn't flat?=20 =20 Or can it handle it and I have to somehow nest views to map the sub arrays? =20 Thanks for any help. =20 ------_=_NextPart_001_01CC2C71.066B52AB--