Domanda

I have saved the user_id() field and now I want to query the datastore for that user. How would I go about accomplishing that?

#Something like
user = db.Query(MyUser).filter('user.user_id() = ', 1234).fetch(limit=1)

Thanks

È stato utile?

Soluzione

You should create a separate string property to store the user ID, then query for that. The UserProperty class is full of traps and is best avoided.

Altri suggerimenti

if what you are searching for is the actual entity Id then you can query for it with the get_by_id method

user = MyUser.get_by_id(1234)

note that if you create it with a parent the you need to pass that to the get_by_id() function too.

user = MyUser.get_by_id(1234, parent=parent)

docs: https://developers.google.com/appengine/docs/python/datastore/modelclass#Model_get_by_id

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top