簡體   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