I'm trying to wrap my head around what seems to be a very simple use case, but I seem to be failing miserably. The goal of the exercise is to look up a set of records for the user that logs in using the Google Accounts username within the high replication datastore and be extremely consistent.
My data looks like this:
class Account(ndb.Model):
owner = ndb.UserProperty()
name = ndb.StringProperty()
class Content(ndb.Model):
content = ndb.StringProperty()
When I first create the account, I just do the following:
current_user = users.get_current_user()
new_account = Account(owner=current_user, name='Some Name')
new_account.put()
Now create content:
new_content = Content(parent=new_account.key, content='Some Content')
new_content.put()
When the user logs in, I can only query by UserProperty, but I seem to be unable to set user as the parent for an entity group, so how do I make sure that I always can look-up the Account by the logged in user and be extremely consistent?
Once I have the account, the ancestor query process will ensure consistency for content retrieval, but I'm stuck on figuring out ancestry based on User.