質問

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

役に立ちましたか?

解決

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.

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top