In ndb, in order to query for items where property A
is in list B
, you can do something like:
Item.query(Item.A.IN(B))
How can you query for items where property A is not in list B?
In ndb, in order to query for items where property A
is in list B
, you can do something like:
Item.query(Item.A.IN(B))
How can you query for items where property A is not in list B?
It's not possible. Note that your IN query is actually automatically broken down into a number of different EQUALS queries, for each item in list B, and the merged results are returned.
You could query for all, and then manually filter out and ignore results that are in list B.
A typical GAE solution would be to denormalize and precompute another value that would be easy to index and query, and save that as a property in Item.
Never say never!
By constructing a series of 'x!=y AND x!=z' ndb filters, we can emulate a 'NOT IN' query: eg (1):
Practically this looks like the following manually-constructed query (2):
Note that simply doing the following also works (3):
Resulting Query: