[英]How to set filtering by ID ndb.query
I try filtering ID such as the following 我尝试过滤如下的ID
ancestorid id value
1111 aaaa 10 // I want to fetch this
1111 bbbb 20
2222 aaaa 30 // and this.
2222 cccc 40
but, I cannot find filtering by id in ndb.query reference. 但是,我在ndb.query参考中找不到按ID进行过滤。
I can filter by key.But It's needed ancestor key(id). 我可以按键过滤。但这是祖先键(id)。 I want to fetch crossing entity group. 我想获取交叉实体组。
How to filter by ID with ndb.query? 如何使用ndb.query按ID过滤?
You can't do that with a single query. 您无法通过单个查询来做到这一点。 That's because if you make an ancestor query you'll only get results from that ancestor entity group and if you don't make an ancestor query you'll only get entities which have no ancestors. 这是因为,如果您进行祖先查询,则只会从该祖先实体组中获取结果;如果您不进行祖先查询,则只会获取没有祖先的实体。 All these queries would have non-overlapping results. 所有这些查询都将具有不重叠的结果。
The only way to obtain the results you want would be with multiple queries: 获得所需结果的唯一方法是使用多个查询:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.