Pregunta

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?

¿Fue útil?

Solución

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)
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top