Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 8650 invoked from network); 25 Jun 2010 16:41:03 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 25 Jun 2010 16:41:03 -0000 Received: (qmail 91761 invoked by uid 500); 25 Jun 2010 16:41:02 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 91717 invoked by uid 500); 25 Jun 2010 16:41: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 91709 invoked by uid 99); 25 Jun 2010 16:41:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jun 2010 16:41:01 +0000 X-ASF-Spam-Status: No, hits=-0.8 required=10.0 tests=AWL,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [64.15.79.181] (HELO iconoclast.caedmon.net) (64.15.79.181) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 25 Jun 2010 16:40:53 +0000 Received: from localhost (localhost [127.0.0.1]) by iconoclast.caedmon.net (Postfix) with ESMTP id EC90278405F for ; Fri, 25 Jun 2010 12:47:42 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at iconoclast.caedmon.net Received: from iconoclast.caedmon.net ([127.0.0.1]) by localhost (iconoclast.caedmon.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HmZsGhhQ2pUW for ; Fri, 25 Jun 2010 12:47:39 -0400 (EDT) Received: from [192.168.145.201] (unknown [173.178.240.142]) by iconoclast.caedmon.net (Postfix) with ESMTPSA id 2EC8878404C for ; Fri, 25 Jun 2010 12:47:39 -0400 (EDT) From: Sean Coates Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Need to "subquery" in a view? Date: Fri, 25 Jun 2010 12:40:28 -0400 Message-Id: To: user@couchdb.apache.org Mime-Version: 1.0 (Apple Message framework v1081) X-Mailer: Apple Mail (2.1081) ("subquery" for lack of a better term) (Apologies if this is a duplicate message. I subscribed in the wrong = order.) Hello. I asked this in #CouchDB, but Jan suggested I also email it here. I have a problem where I have data in couch, and I want to perform what = seems like one too many leaps of logic from within a view. Here's some = sample data: [ {"_id":1,"_rev":1,"type":"user","following":[2,3]}, {"_id":2,"_rev":1,"type":"user","following":[1]}, {"_id":3,"_rev":1,"type":"user","following":[1]}, {"_id":4,"_rev":1,"type":"asset","ownerid":1}, {"_id":5,"_rev":1,"type":"asset","ownerid":1}, {"_id":6,"_rev":1,"type":"asset","ownerid":2}, {"_id":7,"_rev":1,"type":"asset","ownerid":3}, {"_id":8,"_rev":1,"type":"asset","ownerid":3} ] I want to query for a given id where type=3Duser, and get all type=3Dasset= records owned by that user, or by users that the queried user is = following. Here are some examples that hopefully help: _id=3D1; want documents with IDs: [4,5,6,7,8] _id=3D2; want documents with IDs: [4,5,6] _id=3D3; want documents with IDs: [4,5,7,8] I hope that's clear enough. if not, please let me know, and I'll try to = expand my explanation. The foundation of the problem seems to be that from within a map, I = can't fetch secondary type=3Duser documents in order to perform what = amounts to a join (in SQL-speak). Any help is appreciated. I'm currently solving this problem on the app = side, but that's far from ideal (causes a mess with things like limits, = for example). S