Does Firebase allow for dynamic indexes for searches!?
I have the following structure:
PlayerInPool: {
12345: <- PoolId
DUmwewIfzAbfWZN4NjS8mhX82 : true <- UserId
LpWgezRkC6EWS0sjXEWxhFl2 : true
etc...
}
}
I put an observer as such:
ref.queryOrdered(byChild: (Auth.auth().currentUser?.uid)!).queryEqual(toValue: true).observe(.value, with: { snapshot in ...
When I run the app I get the following warning:
[Firebase/Database][I-RDB034028] Using an unspecified index. Consider adding ".indexOn": "DUmwewIfzAbfWZN4NjS8mhX82" at /PlayerInPool to your security rules for better performance
I am trying to do the following in the 'Rules' in Firebase
"PlayerInPool": {
".indexOn" : "auth.uid"
}
but it wont allow it stating that :
Error saving rules - Line 45: Invalid key: auth.uid. Index must be either .value or declared on a valid path
How can I get this to work!?
Updated Comment
If I invert the structure as suggested I would get this:
PlayerInPool: {
DUmwewIfzAbfWZN4NjS8mhX82: <- UserId
12345 : true <- PoolId
98765 : true
LpWgezRkC6EWS0sjXEWxhFl2:
12345 : true
}
}
I'm not entirely sure how this changes anything!?