سؤال

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?

هل كانت مفيدة؟

المحلول

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)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top