You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Luis Carlos Junges <lu...@gmail.com> on 2011/02/22 15:50:20 UTC

Get All Versions of a document

Hi,

How can i get all version from a document? I wil need to it to print a
timeline report.

I just could find on docs retriveing an specific document with the version
in hands, but not all of then.

-- 
"A realidade de cada lugar e de cada época é uma alucinação coletiva."


Bloom, Howard

Re: Get All Versions of a document

Posted by Robert Johnson <ro...@rowanshire.net>.
Carlos

There is a revision number (which is sequential) but you cannot rely on this in 2 cases, first if you are replicating then you may not get all the versions replicated (if a document is updated twice between replication cycles then the intermediate state will not be replicated) second if you compact, old revisions are removed.

You can do several things but 2 spring to mind that I have done which are:-

Attach a timestamp array for updates to the bottom of your document (which is aded to on each update)
Create a new document on each update and link all the revisions with a common key so you can find all the documents with a view - include the document update timestamp in the view and you can get the latest version or the version at a given date quite easily.

Bob

On 22 Feb 2011, at 14:50, Luis Carlos Junges wrote:

> Hi,
> 
> How can i get all version from a document? I wil need to it to print a
> timeline report.
> 
> I just could find on docs retriveing an specific document with the version
> in hands, but not all of then.
> 
> -- 
> "A realidade de cada lugar e de cada época é uma alucinação coletiva."
> 
> 
> Bloom, Howard


Re: Get All Versions of a document

Posted by Henrik Lundgren <ca...@gmail.com>.
>From the Wiki:
http://localhost:5984/my_database/my_document?revs=true

If the document was requested with ?revs=true this field will hold a
simple list of the documents history

Read more here: http://wiki.apache.org/couchdb/HTTP_Document_API#Special_Fields

/Henrik


On Tue, Feb 22, 2011 at 3:50 PM, Luis Carlos Junges
<lu...@gmail.com> wrote:
> Hi,
>
> How can i get all version from a document? I wil need to it to print a
> timeline report.
>
> I just could find on docs retriveing an specific document with the version
> in hands, but not all of then.
>
> --
> "A realidade de cada lugar e de cada época é uma alucinação coletiva."
>
>
> Bloom, Howard
>

Re: Get All Versions of a document

Posted by Jonathan Stott <jo...@gmail.com>.
On 22 February 2011 14:50, Luis Carlos Junges <lu...@gmail.com> wrote:
> How can i get all version from a document? I wil need to it to print a
> timeline report.

The simplest answer is "You shouldn't".

The revisions couchdb stores can't be relied upon for any kind of
document versioning.  They're not always replicated, and are destroyed
on compaction.  If you want to present some timeline of revisions, I
suggest storing some representation of that timeline in an attribute
of the document in question.

Consider adopting a strategy like the one presented here
http://blog.couchone.com/post/632718824

Regards
Jon