Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 87648 invoked from network); 9 Feb 2009 19:31:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Feb 2009 19:31:10 -0000 Received: (qmail 11664 invoked by uid 500); 9 Feb 2009 19:31:04 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 11628 invoked by uid 500); 9 Feb 2009 19:31:04 -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 11617 invoked by uid 99); 9 Feb 2009 19:31:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Feb 2009 11:31:04 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jchris@gmail.com designates 209.85.221.21 as permitted sender) Received: from [209.85.221.21] (HELO mail-qy0-f21.google.com) (209.85.221.21) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Feb 2009 19:30:54 +0000 Received: by qyk14 with SMTP id 14so2848863qyk.11 for ; Mon, 09 Feb 2009 11:30:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=lNhbARs04gS0TqT5TA6DFC1LmAqlE27kc+7dCQR6wxA=; b=kObfJr96bx72JK8Y0YRZuFURI/WEKCHI7/Iwm8pHMHdLZrLZEYRHpd9Og3XmenohEn 5d+XpjmbfJgPlQ7Q8Y7BheVB24oJAlvGQTwE6MXoj59TW5nzU/h6bxpz/e1j7OHlmt9x uMqi/09IPt6ly02iG+1K5eTj5RipBGEGlCtS8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=c/SQo+X2nC/FdRIN1u0Tm+s0me/0ktYcKOlQRuJ97gWTc0g85xw0ZFD5EqjbWWmcNK mgsbTbX98/Pd0HYoWzNVHQlkVa4xgRxkkuMrRCCRogOPxh5C3jHWz+i5KUc25Jg/d3jZ KQov75hnttwaqTYbcrCxBlhJcZT+Zx8nS9yOc= MIME-Version: 1.0 Sender: jchris@gmail.com Received: by 10.214.218.7 with SMTP id q7mr7330985qag.142.1234207830555; Mon, 09 Feb 2009 11:30:30 -0800 (PST) In-Reply-To: <20090208212554.GB11012@uk.tiscali.com> References: <7d8fb2e90902060110me4c87f3q963083913f6e9666@mail.gmail.com> <20090208212554.GB11012@uk.tiscali.com> Date: Mon, 9 Feb 2009 11:30:30 -0800 X-Google-Sender-Auth: 1e5e13c1c2af96e6 Message-ID: Subject: Re: Database Disruption From The Couch From: Chris Anderson To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Sun, Feb 8, 2009 at 1:25 PM, Brian Candler wrote: > > (1) Personally, I'm not yet ready to move all view generation into the > browser (Futon-like), i.e. where Javascript fetches the JSON, reformats as > HTML, and submits back as JSON. In any case, supporting browsers without > Javascript is still a useful capability. The _show and _list features give you the capability to serve HTML or other content types directly based on either doc or view queries. They are a little lacking in documentation, but the test suite should be enough to get your started. > > So for now at least, I still need a layer which will build HTML from a > document, and allow document create/update via form POST. > If it doesn't work already, it'd be trivial to teach Couch to understand norm HTML form POSTs, with some bare-bones conversion to a JSON document (eg: each field is treated as a string, in a flat namespace) > (2) I need an application logic layer, which enforces business rules. > Validation functions can do a lot of this work. One thing that a pure-Couch solution will discourage you from doing, that is considered normal in Rails-style apps, is have one action modify or query lots of documents or views. This is good for latency and cacheability, but may make some applications harder to build. > Put another way: document *storage/replication* and application *processing* > of documents can (and in many cases probably should) remain separate. > Couchapps remain an interesting idea however. Yes. It really depends on your development model. One thing Couchapps have that it's hard to get any other way is the extreme portability. > > This means that the application layer has to fetch the named document, > *then* analyse what type it has, before dispatching to the appropriate > controller/view logic. The way _show and _list handle this is by having named functions, so you'd have a url like /db/_show/myapp/posts/post-id or for authors /db/_show/myapp/authors/author-id of course asking for an error by calling something like /db/_show/myapp/authors/post-id is a problem that Rails avoids due to the Class / Table mapping. > > (4) Error handling: for Javascript user interfaces, if they are going to > rely on the JSON response for failed 'model' validation, then the JSON error > format needs to be carefully described and sufficiently detailled that the > front-end can display meaningful messages to the user, e.g. which particular > fields are invalid and why. Agreed - I'm working on some validation helpers for Couchapp and my Sofa blog. Part of what's up in the air here is where to draw the line between the "standard library" of helpers included with CouchDB, and what should be maintained in its own project. > Map-reduce functions are also going to have to be robust to data of the > 'wrong' type being present. I always check my fields before using them. if (doc.foo && doc.foo.bar ... etc) Good questions. I hope some of what I've written helps. -- Chris Anderson http://jchris.mfdz.com