Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 28016 invoked from network); 30 Jul 2010 19:07:08 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Jul 2010 19:07:08 -0000 Received: (qmail 90418 invoked by uid 500); 30 Jul 2010 19:07:07 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 90263 invoked by uid 500); 30 Jul 2010 19:07:06 -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 90255 invoked by uid 99); 30 Jul 2010 19:07:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jul 2010 19:07:06 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of zachary.zolton@gmail.com designates 74.125.82.180 as permitted sender) Received: from [74.125.82.180] (HELO mail-wy0-f180.google.com) (74.125.82.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Jul 2010 19:07:00 +0000 Received: by wya21 with SMTP id 21so1242040wya.11 for ; Fri, 30 Jul 2010 12:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=s1GgpIjcL+4RnVlovCeE/0BfK18G9kUQi9sM/iW+0OE=; b=ULbBfN1o/CMX6KlcOfP5SRmSaqw7lPy6RBu2UwA20WcPHkjClHCRK1ms4B4q2LLKju XHmnUaxp5dFXO4ERUo9ZZ4YwEs/HY67NSTHYGD8FX5O1BN+YDItbN4wmGzEjnoT2aR56 uP8Wn4xCKbDNMJaWakv5Gue4Ckd3qz5NO2MtA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=sDssjbrff4jD62Rx4A//I3lvpjULsy34ncv56E8Y1e4JhTxL2VO+0KNjyMA74GMiby y3stFEWmOTJWT/hQQ+YxrILGkbAFIP25ty1QuOK2hfkmdnK40NaLHTimCFAFdz4HbYm2 cagwygKBZ06fgiB4Q1QfE1UMW087hal2Fr7hs= Received: by 10.216.30.207 with SMTP id k57mr2065736wea.88.1280516798493; Fri, 30 Jul 2010 12:06:38 -0700 (PDT) MIME-Version: 1.0 Received: by 10.216.159.213 with HTTP; Fri, 30 Jul 2010 12:06:17 -0700 (PDT) In-Reply-To: <30E4B981-E83E-4E8C-9740-55E2AA36AFAE@netdev.co.uk> References: <30E4B981-E83E-4E8C-9740-55E2AA36AFAE@netdev.co.uk> From: Zachary Zolton Date: Fri, 30 Jul 2010 14:06:17 -0500 Message-ID: Subject: Re: Linked Documents To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org John, Short answer: No, during validation you'll need to make decisions solely based on the contents of the document and the user. Generally speaking, all the design doc functions operate in that manner, where you can't make requests to external resources. If you're application can live within those constraints, though, CouchDB gives you quite a bit in return! When you're app constantly has to validate across multiple documents you may get the feeling you're fighting an uphill battle, given that CouchDB only provides atomicity guarantees for single-document operations. In reality, it's often "good enough" to perform some client-side application checks on your data before sending it to the database. Alternatively, you could build a backend program to monitor your data, and even build functionality for your system's expert users to rectify invalid data after-the-fact. My point however is that when deciding CouchDB (or any datastore, for that matter!) you'll need to evaluate how well your app's requirements fit within the database's constraints, and how much you'll need to build into your systems to support its operation. CouchDB works well when each independent document carries with it all the info it needs. Cheers, Zach On Fri, Jul 30, 2010 at 1:32 PM, John wrote: > Hi again > > I didn't get any replies to this post so I'm going to boil it down to a s= imple question which hopefully someone knows the answer to (positive or neg= ative!): > > Can the Design Document functions make database queries? > e.g. If the validation method is being executed and it wants to check a r= eferenced id, can that be done? > > Regards > > John > > Begin forwarded message: > >> From: John >> Date: 26 July 2010 22:38:17 GMT+01:00 >> To: user@couchdb.apache.org >> Subject: Linked Documents >> >> Hi >> >> I have a Use Case where I store an Account Tree in the database. Each Ac= count Node points to its parent and I can resolve the tree using several da= tabase =A0queries by getting the account then its parent then its parents p= arent, I guess you get the idea! >> >> We store data as attributes in these account objects and inheritance is = used to easily propogate attributes down the account tree and override them= at each node as required. >> >> I've just been reading the wiki and seen a nice feature where I can emit= index entries with foreign id's which is great if I already know them in t= he doc my map function is working on however I would prefer to just referen= ce my parent and then *follow* that link to get the parent doc and retrieve= it's parent id from there. >> >> So I guess what I'm trying to ask for here is whether I can retrieve ano= ther =A0document from the database, by id, from within the map function in = a view? >> I can see lots of other places in our design where this could be really = useful especially for validation of referenced id's within documents. >> >> Thanks >> >> John > >