0

I have a realtime database in firebase and have the following query

query(ref(database, 'message/'), orderByChild('ReceiverID'), equalTo("Username"))

But I want to create the following query

query(ref(database, 'message/'), orderByChild('ReceiverID'), equalTo("Username") or orderByChild('SenderID'), equalTo("Username"))

aneuroo
  • 77
  • 1
  • 8
  • 2
    Logical OR conditions are not supported. You will have to perform two queries and combine the results. – Doug Stevenson Dec 16 '22 at 16:21
  • Yeah ok that adds up, need to break away from the SQL way of thinking, thanks for the help and suggestion. – aneuroo Dec 16 '22 at 16:23
  • I find it easiest to think of Firebase Realtime Database results as requesting a single slice of the child nodes under consideration. That's why some AND-type condition are possible (by creating an extra property combining the values), but OR-type conditions aren't (as that'd result in multiple slices). – Frank van Puffelen Dec 16 '22 at 16:31
  • Yes for a "and" statement for the condition would be query(ref(database, 'message/'),orderByChild('ReceiverID'), equalTo("Username"), orderByChild('SenderID'), equalTo("Username")) – aneuroo Dec 16 '22 at 16:36

0 Answers0