I am trying to grab the uid given his email.
I have this:
let usersRef = Database.database().reference().child("users")
usersRef.queryOrdered(byChild: "email").queryStarting(atValue: email).queryEnding(atValue: email).observeSingleEvent(of: .value, with: { (snapshot) in
if let values = snapshot.value as? [String: Any]{
print(values)
}
})
And my database looks as follows:
users
| -$uid
| --email: "some email"
The snapshot doesn't return anything.
Also, the debugger tells me this:
Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ".indexOn": "email" at /users to your security rules for better performance
I think I have done this like so:
{
"rules": {
"users": {
".read": "auth != null",
"$uid": {
".write": "$uid === auth.uid",
".indexOn": ["email"]
}
But this doesn't work as well.
usersRef.queryOrdered(byChild: "email").queryEqual(toValue:email).observeSingleEvent
– 3stud1ant3