Does the engine ndb Key.get application return only the key?

Given the key that I create, I would like to get into the data store to find out if it exists, but I need the cheapest (in time) way to do this. What I'm looking for is like requesting only keys, but from get, for example. my_key.get (keys_only = True). Is there such an animal? It doesn’t look like to me. If not, is there any other way to achieve what I want?

Thank.

+5
source share
1 answer

No, this function does not exist. Since not all objects are indexed, there is no shortcut - the only way to check if a key exists is to try to get it, and then you have entity data available to you for free (in terms of disk operations - there is a bit of serialization, but we do not charge for this).

PS. Are you sure you are not trying to optimize prematurely?

+6
source

All Articles