Shw*_*nka 4 java google-app-engine objectify
如何在客体化中使用"IN"查询?我有一个'纸'实体和一个不同的实体'附表'.在'附表'中我有纸的关键.现在我使用一些标准获得了"纸"的几个键.现在我想用'scheduledDate'来过滤那些.我要查询"日程"像这样的东西: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)
Run Code Online (Sandbox Code Playgroud)
这假定您的Schedule
类有一个字段List<Key> paper
,其中包含指向Paper
实体的键列表(List<Key<Paper>> paper
如果您使用objectify的类型安全Key
s,也可以使用).
注意如何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.
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2465 次 |
最近记录: |