abhishek February 2016
filter by id in ndb model
I am using ndb model as my databse. what i am trying to do is that filter the result on the basis of list of ids.
i have my model like :
userid = ndb.StringProperty()
source = ndb.StringProperty()
handle = ndb.StringProperty()
So i am trying query like this:
I have also tried :
where photoid_list is the list of ids.
Help me out to solve it.
Brent Washburne February 2016
I would suggest that you create keys from each id and then get them all at once:
photo_keys = [ndb.Key(Photo, id) for id in photoid_list]
photos = ndb.get_multi(photo_keys)
The advantage is that a get is faster than a query. Also, ndb will memcache the entities by key and make subsequent gets even faster.
Asked in February 2016
Viewed 2,003 times
Answered 2 times
Leave an answer
Quote of the day: live life