OR in firebase java android

Does anyone know how I can make a general "OR", as in the where clause in firebase?

I need to do this in the request because I am sending the request to the adapter. So, I mean, I cannot add a listener and check one value and then another. I need a full query pointing to this result in my query.

I have something like:

chat1:
   user1Id: "1"
   user2Id: "2"
   bothUsers: "1_2"

chat2:
   user1Id: "2"
   user2Id: "4"
   bothUsers: "2_4"

I need to get all user chats with id "2". I am trying to make a request like:

userLogged = 2;
Query queryRef = firebase.orderByChild("user2Id").equalTo(userLogged);

However, it will only receive chats when user 2 is in position user2Id. But in the above example, when user 2 is in user1Id (chat2), he will not receive. And I need to get it. How can i do this?

+4
1

NoSQL , (. NoSQL Data Modeling). , , :

/userChats
  user1Id
    chat1: true
  user2Id
    chat1: true
    chat2: true
  user4Id
    chat2: true

, I, , Firebase .

+3

All Articles