I'm trying to query my Firebase Realtime Database to find all games a user belongs to.
I have a list of games
, each game has a property of players
. Each child of players
has a key of $uid
, and within that {key: $uid, name: "joe"}
Is it possible to get all games this way? Or do I need to start keeping another index of players_games/$uid/$game
?
I've tried firebase.database().ref('games').orderByChild('players').equalTo(token.uid)
, but this yields null
It looks like database.ref('games').orderByChild('players/${token.uid}')
works, but then I'd need to give .read
access to all of games
, or do this server-side.