Best Practice for CouchDB Document Versioning

Posted by Groundwater on Stack Overflow See other posts from Stack Overflow or by Groundwater
Published on 2011-11-25T22:22:53Z Indexed on 2011/11/26 17:50 UTC
Read the original article Hit count: 204

Filed under:
|
|
|

Following my question here I am exmploring ideas for a generic approach to document versioning in CouchDB. While I imagine there may be no canonical approach, I had the following idea and am looking for feedback.

I would like to maintain readable document ids as much as possible, so a document existing at /document1 would contain a pointer document to all existing versions on the system. The actual revision documents would be at something like /document1/308ef032a3801a where 308ef032a3801a is some random number or hash.

Example

The pointer document

{
    "_id" : "document1",
    "versions" : [ "document1/308ef032a3801a" ]
}

The version document

{
    "_id" : "document1/308ef032a3801a",
    ... actual content
}

© Stack Overflow or respective owner

Related posts about design

Related posts about couchdb