Hi Usul,

On Sun, Apr 27, 2014 at 8:24 PM, Usul <[email protected]> wrote:

> Hi,
>
> I am new to nosql and eventual consistency. What is the recommended way of
> ensuring, that an entity is not created, if it already exists?
>
> For example: A new user should only be created, if the name (=primary id)
> does not exist yet. So if two people create a new user with the same name
> at the same time, one of them should get an error message. Since there is
> no single database, how is it done with google app engine?
>
> I do not need code, I only need to know how it is supposed to be done with
> eventual consistancy. I already read about "Structuring Data for Strong
> Consistency".
>

I can give you code ;-) There is an example in the Python documentation
doing what you describe:

https://developers.google.com/appengine/docs/python/datastore/transactions#Python_Uses_for_transactions

The documentation also mentions a convenience method Model.get_or_insert()
which I had missed the first time around, so thanks for asking this
question.

I don't know about Java on appengine, but I would expect something similar
to exist there.
-- 
Pertti Kellomäki, Kesanto Enterprises
Your training in the cloud: <http://www.trainingcommons.com>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-appengine.
For more options, visit https://groups.google.com/d/optout.

Reply via email to