couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Candler <B.Cand...@pobox.com>
Subject Re: Thoughts on document/views...
Date Thu, 12 Feb 2009 16:03:26 GMT
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.

Mime
View raw message