Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 74579 invoked from network); 12 Feb 2009 16:04:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 12 Feb 2009 16:04:05 -0000 Received: (qmail 51524 invoked by uid 500); 12 Feb 2009 16:04:03 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 51069 invoked by uid 500); 12 Feb 2009 16:04:02 -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 51058 invoked by uid 99); 12 Feb 2009 16:04:02 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2009 08:04:02 -0800 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 b.candler@pobox.com designates 208.72.237.25 as permitted sender) Received: from [208.72.237.25] (HELO sasl.smtp.pobox.com) (208.72.237.25) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Feb 2009 16:03:54 +0000 Received: from localhost.localdomain (unknown [127.0.0.1]) by b-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTP id 130052AF2A; Thu, 12 Feb 2009 11:03:30 -0500 (EST) Received: from mappit (unknown [80.45.95.114]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by b-sasl-quonix.sasl.smtp.pobox.com (Postfix) with ESMTPSA id 6A55B2AA1A; Thu, 12 Feb 2009 11:03:28 -0500 (EST) Received: from brian by mappit with local (Exim 4.69) (envelope-from ) id 1LXe2A-0006Nn-KQ; Thu, 12 Feb 2009 16:03:26 +0000 Date: Thu, 12 Feb 2009 16:03:26 +0000 From: Brian Candler To: Antony Blakey Cc: user@couchdb.apache.org Subject: Re: Thoughts on document/views... Message-ID: <20090212160326.GA24119@uk.tiscali.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17+20080114 (2008-01-14) X-Pobox-Relay-ID: B0BEE54A-F91E-11DD-B31F-6F7C8D1D4FD0-28021239!a-sasl-quonix.pobox.com X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Feb 12, 2009 at 07:27:28AM +1030, Antony Blakey wrote: > CouchRest provides a couchrest-type attribute, which is used for mapping > to a Ruby class. The issue I've had is that dealing with inheritance > requires that each map guard checks the type against a list of possible > classes (for e.g. a subclass test). I thought (for 2 seconds) about > making couchrest-type into a vector, but that fossilizes the inheritance > hierarchy in the data, which is a very bad idea. If you consider it more as a list of mixins than inheritance, it might work. This is roughly what LDAP does: objectClass: top objectClass: person objectClass: organizationalPerson ... You can consider these more as mixins than inheritance. (Actually, an LDAP protocol frontend to Couch would be a cool thing to have anyway, any takers?) > What would be nice is a supported facility for including code in a > design view that is shared amongst all the map/reduce functions in the > view. Then I could code the subclass test as a shared function. Hmm... I know I've seen something like that somewhere. Oh yes, in sofa: $ cat views/comments/map.js function(doc) { // !code lib.helpers.md5 if (doc.type == "comment") { doc.commenter.gravatar = hex_md5(doc.commenter.email); emit([doc.post_id, doc.created_at], doc); } $ cat lib/helpers/md5.js | head /* * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message * Digest Algorithm, as defined in RFC 1321. ... etc Perhaps the library is being inserted in-line by CouchApp though, when uploading it.