incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <robert.new...@gmail.com>
Subject Re: About _id generation rule
Date Mon, 21 Feb 2011 01:11:27 GMT
It's worth noting that couchdb only generates a _id if you don't
choose one for yourself. I'm often surprised when people assume that
they must use a uuid, and particularly surprised when they think they
have to use the ones we generate.

In the case that you simply don't care about the id of your documents
then by all means POST to the /db resource. Bear in mind that multiple
posts might occur if there's a problem (some browsers do this, iirc).
If you have a natural key, then it's usually better you use that,
especially if you need to detect conflicting updates.

B.

On 20 February 2011 19:59, Dmitry Unkovsky <oil.crayons@gmail.com> wrote:
> As I can grasp in src/couchdb/coudh_uuids.erl, dependent on chosen
> uuids algo in config you either take
> a) random 16 bytes;
> or b) 14 hex-microseconds digits catenated with 9 randomly generated bytes;
> or c) 13 bytes of semi-constant prefix concatenated with 6 hex digits
> incremented by rand(1,0xffe), where prefix is randomly updated once
> total increment is greater than 0xfff000.
>
> No other kind of tricks. I'd just make sure my ids would not easily
> overlap, probably java uuids should be good enough.
>
> On 20 February 2011 21:48, sleepnova <wanpeebaw@gmail.com> wrote:
>> Ha, I know the host uuids request trick.
>> But it doesn't solve my problem, I need to generate it offline.
>> Right now I use Java API to generate UUID and strip all "-" in it to
>> make it looks like an _id generated by CouchDB.
>> But I wonder if this approach is good enough, or there are some better
>> way to make my _id more appropriate.
>> Because I don't know if Couch plays any trick on the auto generated
>> _id that could make some different to the internal storage.
>>
>> 2011/2/21 Bill Barry <bill@billbarry.org>:
>>> On Sun, Feb 20, 2011 at 11:19 AM, sleepnova <wanpeebaw@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> Does any one know what is the CouchDB _id generation rule?
>>>> I'd like to generate it from my client.
>>>>
>>>>
>>> Not to directly answer your question because I don't know how CouchDB
>>> generates the UUIDs, but any UUID generator should work. You can also
>>> request them from the host using a GET to /_uuids  or if you want 10 of
>>> them   /_uuids?count=10
>>>
>>> Bill
>>>
>>
>> --
>> - sleepnova
>>
>
>
>
> --
> DU
>

Mime
View raw message