I know there’s a way to get a certain entity based on its key ID using get_by_id(someId), but is there any way to get several entities with ID higher than some specified value? With a regular filter, we can do query.filter("customId >", someId), but how can I do this for the built in key ID?
I know there’s a way to get a certain entity based on its key
Share
Even though the Key looks like a big meaningless string, it’s actually a combination of your application ID, the type of entity and then either the numeric auto-assigned ID, or the you-generated key-name (parents and namespaces are in there too, but the same basic principles apply).
When you do a < or > comparison, or use ‘order by’ in a query, it’s against these individual parts, rather than the string-encoding you see. So given that the app-ID and entity-type are the same, then you’ll be comparing or sorting by the ID or key-name parts. The documentation explains it here.
In the filter method you can use ‘__key__’ as the property name, and then construct a Key object (in python at least) using Key.from_path