![](/img/trans.png)
[英]How can i retrieve the fields from the firebase structure instead of the Boolean values?
[英]firebase query how can i retrieve two specific values from child
我使用 recyclerview 檢索聊天消息,我想知道是否有檢索兩個不同值的方法,我的意思是這樣的:
FirebaseRecyclerOptions<enchat> options =
new FirebaseRecyclerOptions.Builder<enchat>()
.setQuery(
mChatDatabase.orderByChild("state").equalTo("sent")
&& mChatDatabase.orderByChild("state").equalTo("received"),
enchat.class)
.build();
無法將兩個值傳遞給一個條件。 Firebase 實時數據庫不支持此類 OR 條件。
另見:
常見的解決方法是:
執行兩個查詢並將結果合並到您的應用程序代碼中。 但是在這種情況下,您將無法使用來自 FirebaseUI 的適配器。
執行范圍查詢,但這僅在received
和sent
之間沒有state
值時有效。 如果是這種情況,查詢可能是:
mChatDatabase.orderByChild("state").startAt("received").endAt("sent")
添加一個附加屬性,該屬性在received
或sent
state
時為真,並對其進行過濾:
mChatDatabase.orderByChild("stateIsReceivedOrSent").equalTo(true)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.