![](/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.