You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Robert Sosinski <em...@robertsosinski.com> on 2010/10/05 04:19:58 UTC

How Does CouchDB Generate _rev Strings

Hello,

I just wanted to ask how CouchDB generates the string used for the
_rev.  The first part (being the number) is pretty self explanatory.
However, I have not yet figured out how the second part that looks
like a MD5 digest is created.  Would it be possible to
deterministically predict the _rev "digest" before saving the
document?

Any clarification would help.

Thanks,

-Robert

Re: How Does CouchDB Generate _rev Strings

Posted by Volker Mische <vo...@gmail.com>.
On 05.10.2010 04:19, Robert Sosinski wrote:
> Hello,
>
> I just wanted to ask how CouchDB generates the string used for the
> _rev.  The first part (being the number) is pretty self explanatory.
> However, I have not yet figured out how the second part that looks
> like a MD5 digest is created.  Would it be possible to
> deterministically predict the _rev "digest" before saving the
> document?
>
> Any clarification would help.
>
> Thanks,
>
> -Robert

Hi Robert,

have a look in the CouchDB Definitive Guide:
http://guide.couchdb.org/draft/conflicts.html#deterministic

Cheers,
   Volker

Re: How Does CouchDB Generate _rev Strings

Posted by Sebastian Cohnen <se...@googlemail.com>.
I partly explained this some time ago on this ML. I'll c&p it quickly and hope it helps

> consider the _rev token as an opaque value necessary for the mvcc (I'd call it mvcc-token, since "revision" is often misunderstood). The hash algorithm may even change someday. AFAIK it contains the document itself and also its history (at least parts of it). The algorithm ensures that the same document with the same history result in the same _rev token even on two different nodes. This behavior is required for conflict detection/resolution.

Best

Sebastian

On 05.10.2010, at 04:19, Robert Sosinski wrote:

> Hello,
> 
> I just wanted to ask how CouchDB generates the string used for the
> _rev.  The first part (being the number) is pretty self explanatory.
> However, I have not yet figured out how the second part that looks
> like a MD5 digest is created.  Would it be possible to
> deterministically predict the _rev "digest" before saving the
> document?
> 
> Any clarification would help.
> 
> Thanks,
> 
> -Robert