繁体   English   中英

在对象化中使用'IN'查询

[英]Using 'IN' query in objectify

如何在objectify中使用“ IN”查询? 我有一个“纸”实体和一个不同的“时间表”实体。 在“计划”中,我有纸质钥匙。 现在,我使用一些条件获得了一些“ Paper”键。 现在,我想用“ scheduledDate”过滤那些。 我想用类似这样的查询'Schedule': get 'schedule' from 'Schedule' where 'paper key' in (List of paper keys) and 'scheduledDate' = 'some date' 我如何客观地做到这一点? 谢谢

Objectify是低层数据存储区API的精简包装,因此IN运算符的行为与低层API相同:

ofy.query(Schedule.class).filter("paper IN", listOfPaperKeys).filter("scheduledDate = ", someDate)

这假设您的Schedule类具有一个字段List<Key> paper ,该字段包含指向Paper实体的键的列表(如果使用objectify的类型安全Key则也可以具有List<Key<Paper>> paper )。

注意IN如何IN执行一系列查询并组合结果。 因此,从某种意义上讲,它表现为一系列“ =”运算符,其结果被合并:

The IN operator also performs multiple queries, one for each item in the 
specified list, with all other filters the same and the IN filter replaced with
an EQUAL filter. The results are merged, in the order of the items in the list. 
If a query has more than one IN filter, it is performed as multiple queries, 
one for each possible combination of values in the IN lists.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM