0

I'm trying to compare the unique numerical id of an element in my database with a list of longs.

My GQL query should return those elements which have this id I'm passing as part of their array of longs.

I've tried using a statement of the form:

"SELECT * FROM Table WHERE id IN :1", list_of_stored_ids

I've also tried using this question: GQL query with numeric id in datastore viewer, but I still can't find any way to compare to a list.

Is there such a way? If not, what must I do?

Community
  • 1
  • 1

1 Answers1

0

You will need to build up a list of ndb keys, not numeric ids, in order to get this to work.

eg:

ids = [5918782761467904, 5624113645223936, 5463928544952320]
keys = [ndb.Key('<Entity>', id) for id in ids]
entities = ndb.gql("SELECT * FROM <Entity> WHERE __key__ IN :1", keys).fetch()

or (non-GQL version)

entities = ndb.get_multi(keys)
ChrisC73
  • 1,833
  • 14
  • 14