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
Post a Comment