Appengine ndb - How to ensure unique username and email without ancestors?
In my Appengine (using ndb) application I store users and both username and email need to be unique. I also need to be able to update progress (save level if higher than previously stored level), change email and pw and delete account. I noticed that it is not possible to query without ancestors in a transaction. But creating an ancestor is NOT a solution since that would limit the number of writes to 1 per second which is not OK if the app gets popular. So I need another solution. Is it possible to use the Key? Yes, but that only makes the username unique, how can I make sure noone is reusing the email for another account?
You should be able to use a cross group transaction for this along with an entity that exists solely for reserving email addresses. For your User entity, you could use the username as the key name. When creating a user, you also create an EmailReservation entity that has the user's email address as a key name. You then use a cross-group transaction to create a new user: #ndb.transactional(xg=True) def create_user(user_name, email): user = User.get_by_id(user_name) email_reservation = EmailReservation.get_by_id(email) if user or email_reservation: # Either the user_name or email is already in use so stop return None # Create the user and reserve the email address so others can't use it user = User(id=user_name) email_reservation = EmailReservation(id=email) ndb.put_multi(user, email_reservation) return user
Trouble locating static audio file on Google App Engine
Final GAE vs AWS architectural decision
how to read ZipInputStream into CharArrayReader
Google app engine: personal experiences?
Uploading multiple files to blobstore (redux)
App Engine: Can I upload my local dev_appserver.datastore to the live datastore?
App Engine URL mapping
Sitemaps structure for large App Engine site
cheetah in appengine
Help to Upload zip file containing CSV file in GAE
Google App Engine: Using datastore with users who are not logged in
Text to HTML converter for Google App Engine
Pagination and Multiple relational entity indexes with AppEngine
time taken to upload a picture of 1M ~ 5M from iPhone to either Google AE or Amazon S3
Sending email from dev server with --smtp_host=smtp.gmail.com
Google App Engine logout url