couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <>
Subject Re: Selectively keeping revisions around
Date Tue, 22 Jul 2008 20:50:25 GMT

On Jul 22, 2008, at 19:22 , Kurt Mackey wrote:

> I'm admittedly pretty new to CouchDB, but I'm having a tough time  
> figuring out how to use the document revisions it keeps around.  As  
> I understand it, PUTs replace what's there, leaving what's there in  
> a deleted state until you compact the database, at which point it  
> goes away forever.
> So given that (and correct me if I got it wrong), what's the best  
> way of keeping revisions around forever?  I have a number of  
> documents that will be changed quite frequently, and I'd like to get  
> at their history, provide diffs against it, etc.  Is anyone doing  
> this?

Sorry to disappoint you.

Do not rely on the revisions for what you want to do.
Only go with the no-compaction route if you have
very little data.

To keep documents around you can do two things:
   1) Save old revisions as attachments to the most
recent revision.
   2) Save old revisions as new documents.

Both come with advantages and disadvantages and
both seem clumsy in the light of possibly using the
built in revision system. We'd like to have the revision
system work as you want to use it, but getting it right
with the distributed replication is kinda tricky, so we
don't do that as of yet and you should not rely on it.

1) Advantages
All data is available under a single doc id.

1) Disadvantages
You need to copy around revisions manually.
Can't use the structure of your old revisions in views.

2) Advantages
You can use your old revisions in views.
You can use view to collect a doc and all revisions

2) Disadvantages
Data is spread over multiple doc ids.

(There might be more, I'm kinda short on time at the moment,
fill in the blanks please :)


View raw message