0

I am using firebase realtime db. I want to get data from firebase with react-firebase-hooks/database library.

I want to get users with certain ids. I know how can i get one user:

const user = useObjectVal(ref(myDB, "users/123")) // where id = 123

but what if i need users with id = 123 and id = 456? How can i get data for only two documents from firebase?

I just want something like this:

const user = useObjectVal(ref(myDB, "users/123&456")) // where id = 123

Lamer_2005
  • 387
  • 2
  • 4
  • 9
  • 1
    according to the docs https://github.com/CSFrequency/react-firebase-hooks/tree/master/database#full-example you have just 2 options: fetch a single user or the list. Maybe you can simply use 2 variables with userA and userB? – Anton Jul 11 '22 at 22:31

1 Answers1

1

There is no way to perform an OR with multiple values in the Firebase Realtime Database API. You'll have to perform a separate query for each value and merge the results in your application code.

Also see my answer here: iOS - OR query in Firebase

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807