From couchdb-user-return-188-apmail-incubator-couchdb-user-archive=incubator.apache.org@incubator.apache.org Fri Apr 11 22:28:14 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 28532 invoked from network); 11 Apr 2008 22:28:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Apr 2008 22:28:14 -0000 Received: (qmail 37145 invoked by uid 500); 11 Apr 2008 22:28:13 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 37119 invoked by uid 500); 11 Apr 2008 22:28: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 37110 invoked by uid 99); 11 Apr 2008 22:28:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 15:28: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 guby.mail@gmail.com designates 64.233.178.251 as permitted sender) Received: from [64.233.178.251] (HELO hs-out-0708.google.com) (64.233.178.251) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 22:27:30 +0000 Received: by hs-out-0708.google.com with SMTP id 23so187336hsn.12 for ; Fri, 11 Apr 2008 15:27:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to:content-type:content-transfer-encoding:mime-version:subject:date:x-mailer; bh=Q1YRmxq+ZUlJqOn/rmKL/xE4V+NL+BBfeZIIxduCpx8=; b=Ui0szfWyeUb5D4b/Se+TtQMZ1NyNTjEfy3/xD9PX/h0XnCIQVCWJisSkpadqjA7BcGO1IHfanQIySYiqmIqTGx2cAzcfUga2NWKtFz20jhPFZRqsBi4vRt1GsPJHw4eVbDwbx0BwULt85mVYl5Ksl6yKqCat24VH/cOTJGdGtDA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding:mime-version:subject:date:x-mailer; b=Jzy869QKjLWiYx/exZP/nM+gibRFQZABFiuG5vYDkA7O5L+1IVLV49UMJOLJJXyqg++M/b1DEnKATnLelKK14jd0LZzl07iNyidyeQuiJf5+9q8uwxoKpSAHPEA95sISF9NPCuZ1A6jC/h0xR/3D0sHXwq/xB36AGhiaeJ+xsJk= Received: by 10.100.37.20 with SMTP id k20mr6421174ank.5.1207952862246; Fri, 11 Apr 2008 15:27:42 -0700 (PDT) Received: from ?192.168.1.101? ( [200.89.150.124]) by mx.google.com with ESMTPS id h36sm12857176wxd.29.2008.04.11.15.27.41 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Apr 2008 15:27:41 -0700 (PDT) Message-Id: <6004BDC3-1BE5-4395-96D0-3596A105E292@gmail.com> From: Guby To: couchdb-user@incubator.apache.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Loading another object to return in a view! Date: Fri, 11 Apr 2008 19:26:44 -0300 X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org Dear CouchDB developers and users. I have another view related question. What I am trying to do is this: Every document of type X has stored a reference to document Y. Based on certain parameters in X i decide whether or not to load and return document Y from the DB. The view code I am trying to use looks something like this: function(doc){ if (doc.class == "OfTypeX" && doc.an_attribute == true){ var db = new CouchDB("mydb"); var doc2 = db.open(doc.id_of_object_Y); map([doc.another_attribute, doc.id_of_Y], doc2); } } Whenever I include the line "var db = new CouchDB('mydb');" in my view everything stops... It works perfectly in the Javascript Shell though! Any ideas? Aren't you allowed to access the DB directly from a view? Is there a way to access other documents than the one being passed in to the view, from a view? I realize though that these kinds of views might lead to stale data as the view index doesn't get updated if the document Y gets updated, but that is all right in my case. Best regards Sebastian