在 ndb 中,如何查询属性 A 不在列表 B 中的项目? [英] In ndb, how to query for items where property A is not in list B?
问题描述
在 ndb 中,为了查询属性 A
在列表 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))
如何查询列表 B 中属性 A 不 的项目?
How can you query for items where property A is not in list B?
推荐答案
这是不可能的.请注意,对于列表 B 中的每个项目,您的 IN 查询实际上会自动分解为多个不同的 EQUALS 查询,并返回合并的结果.
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.
您可以查询所有,然后手动过滤并忽略列表 B 中的结果.
You could query for all, and then manually filter out and ignore results that are in list B.
典型的 GAE 解决方案是对另一个易于索引和查询的值进行反规范化和预计算,并将其保存为 Item 中的属性.
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.
这篇关于在 ndb 中,如何查询属性 A 不在列表 B 中的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!