I have a database like this
users/UID1/"Username" (of user 1)
/UID2/"Username" (of user 2)
/UID3/"Username" (of user 3)
/UID4/"Username" (of user 4)
and so on..
I would like to check if the username exist but I don't manage to go in a loop with all existing UID. For now I have tried :
let databaseRef = Database.database().reference()
databaseRef.child("users").child("uid").child("Username").observeSingleEvent(of: DataEventType.value, with: { (snapshot) in
switch snapshot.value {
case let value as Bool where value:
// value was a Bool and equal to true
print ("username found")
default:
// value was either null, false or could not be cast
print ("username not found")
}
})
}
I don't know what to put instead of child("uid") to loop into every uid in my database and check if a username exists
Thanks for your help !