문제

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