google cloud datastore - filter by id in ndb model -


i using ndb model databse. trying filter result on basis of list of ids. have model :

class photo(ndb.model):    userid = ndb.stringproperty()     source = ndb.stringproperty()    handle = ndb.stringproperty()    sourceid =ndb.stringproperty() 

so trying query this:

              queryset=photo.query(photo.key.id().in(photoid_list)) 

i have tried :

              queryset=photo.query(photo.id().in(photoid_list)) 

where photoid_list list of ids. me out solve it.

i suggest create keys each id , them @ once:

photo_keys = [ndb.key(photo, id) id in photoid_list] photos = ndb.get_multi(photo_keys) 

the advantage faster query. also, ndb memcache entities key , make subsequent gets faster.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -