Auto increment with datastore

2,540 views
Skip to first unread message

syahreza.octadian

unread,
Nov 9, 2008, 11:20:31 PM11/9/08
to Google App Engine
Dear all,

I'm new with google app engine, now i'm try to build simple task
management with this. But i have some of problem with datastore, i
don't have any idea to create auto increment in data store.



Thank for any suggestion....
Syahreza Octadian

djidjadji

unread,
Nov 10, 2008, 2:46:13 AM11/10/08
to google-a...@googlegroups.com
There is no such feature, but you can create one yourself.
Have a look at
http://sites.google.com/site/io/building-scalable-web-applications-with-google-app-engine
and the subject about distributed counters

2008/11/10 syahreza.octadian <syahreza...@gmail.com>:

Barry Hunter

unread,
Nov 10, 2008, 5:38:14 AM11/10/08
to google-a...@googlegroups.com
When you say "auto increment" - do you really mean 'unique primary key'?

If so see:
http://code.google.com/appengine/docs/datastore/keysandentitygroups.html

but note "An application should not rely on numeric IDs being assigned
in increasing order with the order of entity creation. This is
generally the case, but not guaranteed."

as mentioned if you want an exact numberical order then you will need
to make it yourself, and will need a counter. But you must be very
careful to ensure consistancy, it would be very easy for a counter to
get out of sync with a high insert rate.

So unless you really need strict sequencial number I would recommend
using what is provided by the datastore.

--
Barry

- www.nearby.org.uk - www.geograph.org.uk -

Reply all
Reply to author
Forward
0 new messages