10
votes

With the old db, I could call Model.get_by_id([1, 2, 3]) to get a list of entities.

Ndb's Model.get_by_id doesn't support a list of ids as a parameter. What's the best way to replicate the old functionality?

1

1 Answers

20
votes

You use the function get_multi which takes a list of keys.

objects = ndb.get_multi([ndb.Key(Model, k) for k in ids])