Question

I couldn't find this in documentation. I'm checking the existance of multiple keys in datastore in single AppEngine request. Is it possible to do this in a single query, since this would be much more efficient then sending multiple get_by_id requests?

Was it helpful?

Solution

You can Create a RPC request to get entities by key with lookup method of Google Cloud Datastore:

request = datastore.LookupRequest()
request.key.extend(list_of_keys)
response = datastore.lookup(request)

Or faster:

list_of_entities = ndb.get_multi(list_of_keys)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top