incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ara.t.howard" <ara.t.how...@gmail.com>
Subject Re: uuid, auto-increment, et al.
Date Mon, 20 Oct 2008 22:01:12 GMT

On Oct 20, 2008, at 3:31 PM, Nick Johnson wrote:

>
> If you have 'user' docs and 'email' docs (which may simply contain  
> nothing
> but a reference to the user that owns the email), you can attempt to  
> insert
> both a new user doc and a new email doc in a single bulk write  
> transaction.
> The transaction will fail if either one already exists.
>
> This doesn't really work with my proposed sharding method, however,  
> since
> you can't guarantee both entities will hash to the same shard. You  
> could
> insert one doc then the other, and if the second insert fails, roll  
> back the
> first one, though.

heh - this is my current approach

http://s3.amazonaws.com/drawohara.com.snippets/create_user_with_unique_fields_rb.html

note that doing it in bulk results in non-obvious error codes for the  
user - you can't tell them *what* failed - but this approach does let  
you do that and makes sure the object is not marked as a user until  
it's 'fully baked'.  it also allows for cleanup after a kill -9

cheers.

a @ http://codeforpeople.com/
--
we can deny everything, except that we have the possibility of being  
better. simply reflect on that.
h.h. the 14th dalai lama




Mime
View raw message