I have a few doubts regarding using python ndb. I am using proto datastore. I have a class User
class User( EndpointsModel ):
name = ndb.StructuredProperty( Name, required=True )
dateOfBirth = ndb.DateProperty(required=True)
userName = ndb.StringProperty( required=True )
emailId = ndb.StringProperty( required=True )
I want to fetch user entity based on usernames. When i create a new User object and do
user.id = username
I get error "ID must be an integer.", how do i overcome this. Also would user.get_by_id() be faster than User.query( User.username == username ) ?
If i want all the username's to be unique, do i have to create an entity of username's and check whenever a new user is created if its already present or is there some other neat and efficient way to do this.