Using entity key to retrieve entries from datastore
-
10-10-2019 - |
Question
My Datastore contains: an entry with an id/Name id = 30001
I tried: SELECT * FROM Skill WHERE Id=30001
and a few other variations.
How can i use the entity key to retrieve entries?
Solution
The fastest and more convenient method to retrieve a Model by a given id is by calling the get_by_id() class method of the Model:
skill = Skill.get_by_id(30001)
Using GQL is pretty much slower and it's achieved using KEY
:
SELECT * FROM Skill WHERE __key__ = KEY('Skill',30001)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow