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 8415D66A1 for ; Sun, 22 May 2011 20:52:33 +0000 (UTC) Received: (qmail 6467 invoked by uid 500); 22 May 2011 20:52:31 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 6434 invoked by uid 500); 22 May 2011 20:52:31 -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 6426 invoked by uid 99); 22 May 2011 20:52:31 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 May 2011 20:52:31 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sean.copenhaver@gmail.com designates 74.125.83.52 as permitted sender) Received: from [74.125.83.52] (HELO mail-gw0-f52.google.com) (74.125.83.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 May 2011 20:52:25 +0000 Received: by gwj15 with SMTP id 15so2621902gwj.11 for ; Sun, 22 May 2011 13:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:message-id:in-reply-to:references :subject:x-mailer:mime-version:content-type :content-transfer-encoding; bh=UUhlNyPpmYPFivNJW190WEit13O5cTCqd98s+q89JAM=; b=AnMLQTWtsZoWeXZttLmN51fTiPHu8tCT1vd3ze54Q112oDe/QeOIowLpR82xU7rY+e 7OgKy9X82TXM+iEa94S+q7b1KR6lBxcuCvqn7y65hnMKROo9uj6tHqCHCbuhOQeq4SCL SutqDRq9H+KgcVV5X+ZP72JOiITkjRNBGt8Ic= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:message-id:in-reply-to:references:subject:x-mailer :mime-version:content-type:content-transfer-encoding; b=VnyhLc3cmk3FDK6MVoXZELBS54R24iforvlqW45FPfKUlalGmablLl6lPjARIdtZMR gdSKAvNslZLSvn58QbTrkEH6ZxqqDBn+hRuiSJA5xjWPpFLt1WOiIZ3AZKl4RUDaVTZ7 aSQuGl4T/pq1LlOb21yC1kzsmsCpUnO+U0WwE= Received: by 10.236.193.98 with SMTP id j62mr2069395yhn.46.1306097524440; Sun, 22 May 2011 13:52:04 -0700 (PDT) Received: from copenhas-mbp.local (99-98-235-230.lightspeed.clmasc.sbcglobal.net [99.98.235.230]) by mx.google.com with ESMTPS id x37sm4288134ana.34.2011.05.22.13.52.03 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 22 May 2011 13:52:04 -0700 (PDT) Date: Sun, 22 May 2011 16:52:02 -0400 From: Sean Copenhaver To: user@couchdb.apache.org Message-ID: <7947C08316334ED196B54A6C87454BA2@gmail.com> In-Reply-To: <20110522163801.1831e9e1.mk@cognitivedissonance.ca> References: <20110522134328.345ba41b.mk@cognitivedissonance.ca> <3E6584270538455D81B24B1A8EF11032@gmail.com> <20110522163801.1831e9e1.mk@cognitivedissonance.ca> Subject: Re: couchDB and node.js double bind X-Mailer: sparrow 1.0.1 (build 589.16) MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="4dd97772_43f18422_1fa" Content-Transfer-Encoding: 8bit --4dd97772_43f18422_1fa Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Content-Disposition: inline If the relationships were bi-directional then perhaps your map function could look like this: function(doc) { emit([doc._id], null); for(var i = 0; i < doc.related.length; i++){ emit([doc.related[i], doc._id], null); } } When you query for a specific doc id you would get that document plus all the other related documents. Something like: _view/view?startkey=[],include_docs=true If they were one way then yeah, I believe you would need to do some looping or make a second request. -- Sean Copenhaver Sent with Sparrow On Sunday, May 22, 2011 at 4:38 PM, MK wrote: > On Sun, 22 May 2011 14:12:05 -0400 > Sean Copenhaver wrote: > > I hope I understand what you are after, but here's what I got. You > > have a parent document that has a list of ids for it's children or > > some sort of related documents? You want to be able to query for the > > parent in the relationship and get a list of children ids with a > > short description? > > > > Sounds like you need to reverse the relationship (or make it > > bi-directional). Have the children keep an id to their parent > > All the documents have exactly the same structure -- there is no > parent/child relation -- which includes a short description and an > array of other (identically structured docs) to which this one is > related. I want to display one of these, and in the display, list the > related docs including their short desc. > > > -- > "Enthusiasm is not the enemy of the intellect." (said of Irving Howe) > "The angel of history[...]is turned toward the past." (Walter Benjamin) > --4dd97772_43f18422_1fa--