On 31/12/2008, at 11:29 PM, Geir Magnusson Jr. wrote:

What trouble? I think this is *exactly* what should be done - have CouchDB store documents that are :

{
metadata : { _rev : X, _id : Y, _woogie: Z, .... anything that needs to be added in the future, like other metadata like last update date... },
   userdata : {  .... the document you want to store .... }
}

and then offer APIs that let you :

a) get to this document, for libraries and clients that know they are talking to Couch and want to manipulate at this level

b) return and accept the userdocument directly, for clients that just want to consume or produce JSON data, w/o caring about the internal housekeeping

One of the issues complicating the logic of this discussion is that the document id is both metadata and, conceptually, a document member. That's why, although the purest model is to have the userdata as a member within a Couch document as you suggest, this doesn't look that appealing:

{
  metadata: {
    id: ...
    rev: ...
    ...
  }
  data: {
    ... the user's document ...
  }
}

Furthermore, from a scalability perspective, always having the metadata when you have the document, isn't a problem - the metadata is constrained. The reverse situation of always having the data when you have the metadata, is not constrained because the data is arbitrarily large. IMO this means that a solution such as this:

{
  id: ...
  rev: ...
  ...
  data: {
    ... the user's document ...
  }
}

isn't such a good idea compared to this:

{
  _metadata: {
    id: ...
    rev: ...
  }
  ... the user's document ...
}

Unfortunately the reserved token makes the structure non-reflexive without transformation, and although that's not currently an issue, I can imagine it complicating certain use-cases. It makes the system more complicated to reason about.

I'm struggling to objectively evaluate this model and your reflexive model - given Damien's attitude to this issue, my motivation to do so is somewhat depressed :/

Antony Blakey
-------------
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

Did you hear about the Buddhist who refused Novocain during a root canal?
His goal: transcend dental medication.


Reply via email to