Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 65016 invoked from network); 11 Apr 2008 23:48:04 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Apr 2008 23:48:04 -0000 Received: (qmail 11879 invoked by uid 500); 11 Apr 2008 23:48:04 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 11859 invoked by uid 500); 11 Apr 2008 23:48:04 -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 11850 invoked by uid 99); 11 Apr 2008 23:48:04 -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 16:48:04 -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 209.85.132.251 as permitted sender) Received: from [209.85.132.251] (HELO an-out-0708.google.com) (209.85.132.251) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Apr 2008 23:47:21 +0000 Received: by an-out-0708.google.com with SMTP id b33so163926ana.83 for ; Fri, 11 Apr 2008 16:47:33 -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:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer; bh=rX0syQJrA2yWau+6hTFwVqlAKFH/AqPnNRXgFw51uT0=; b=KSg0bH5dNzIq7RI9NDef+fdnwh+5Bzu9RqrvSy6YW1D+CQj2BODpzQDVNkh0lYtbkAwetJBHg/BIuldEifEu6wwCNwF/+qNqL8iOIPfgEoOKMjrXDO3Nlr0y4z7XJ3m8FHp7+P4MisObT24neUCzYxfpJwcLTnGxs/F2MGiy38w= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:in-reply-to:content-type:content-transfer-encoding:mime-version:subject:date:references:x-mailer; b=VAUxEdFpRt198dj1G98A46HFhnGreUUw0D77MZ8tHDKgltJsiDwqFdhi/T4bsgeFybw9/Dlx45ettKL9spCTyI9AXC1m1ZLQqMpYuHtwOjexEnztb/Go8VsaFb2mBMNa+nmMFog4dCUwikEqV14INxA7XZeRF8HJWD2SswCgdSk= Received: by 10.100.122.8 with SMTP id u8mr6447432anc.103.1207957652775; Fri, 11 Apr 2008 16:47:32 -0700 (PDT) Received: from ?192.168.1.101? ( [200.89.150.124]) by mx.google.com with ESMTPS id h15sm6704982wxd.23.2008.04.11.16.47.30 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 11 Apr 2008 16:47:31 -0700 (PDT) Message-Id: <4FBAE099-0A64-4309-AFAE-CE63E4B1AA56@gmail.com> From: Guby To: couchdb-user@incubator.apache.org In-Reply-To: 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: Re: Loading another object to return in a view! Date: Fri, 11 Apr 2008 20:46:33 -0300 References: <6004BDC3-1BE5-4395-96D0-3596A105E292@gmail.com> X-Mailer: Apple Mail (2.919.2) X-Virus-Checked: Checked by ClamAV on apache.org Maybe I wasn't clear. It is nothing ajax like. What I am trying to accomplish is that when document X is indexed by the view server, it maps parts of document Y in addition to itself. I have seen the CouchDB class being used in the test suite in the couchDB interface, so I thought that was something that also would be available in the views?! But it is not? Is there no way for a view, indexing the document X, to access the database and get some info? Best regards S On Apr 11, 2008, at 8:11 PM, Jan Lehnardt wrote: > Views do not run in the context of a browser. So you don't have any > AJAX features there. The map function gets executed in a very > isolated environment. > > You could hook up a different language interpreter for your views > that let's you access external resources, but you'd be pretty much > on your own support-wise. > > Cheers > Jan > -- > > > On 12 Apr 2008, at 00:26, Guby wrote: > >> 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 >>