0

i'm developing a chat system where i have a chat room that store the id's of the sender and receiver at this room , i want to query on this room where the current logged in user id is equal to sender or receiver id in the chat room collection.

i've used this as follows

final docRef = db.collection("chat-rooms").where('user_1',isEqualTo: Account.current.uid);

but this only works only on the field ' user_1 '

enter image description here

  • 1
    what is it that you want to get from firestore? – Delwinn Jun 05 '22 at 17:28
  • 1
    Firestore does not have logical OR queries among multiple fields. You will have to perform one query for each field you want to check, then merge the results in the client app. – Doug Stevenson Jun 05 '22 at 18:32
  • @Delwinn the user id may be in user 1 on user 2 so i want to validate it like this – نعمان منذر محمود الجميلي Jun 05 '22 at 19:35
  • @DougStevenson this would not give me an accurate result . let's say that i am user one and you user2 . if i used the app to retrieve the rooms that belong to me . i may be user_1 if i opened the room firstly or user_2 if i been added to the room. so i need use the OR principle . – نعمان منذر محمود الجميلي Jun 05 '22 at 19:38
  • You're going to have to find a way to get what you want without using an OR query. It will be possible. If you're having problems coming up with the algorithm, post a new questions with the queries you're using and results that you have so far, where you are stuck computing the final result. – Doug Stevenson Jun 05 '22 at 19:53

0 Answers0