I try to prevent the creation of already existing usernames.
This is my code where I upload usernames to the database:
ref?.child(\"users\").child(FIRAut
You can only query for values that are at a directly under the reference you query at. For your case that would be with a data model like:
Database_App {
users {
-3bSRmS4PHXUwsr7XbMBwgPozNfK2: "sebas.varela"
}
}
This will work in your code, but is hard to get secure and performant. The more common approach is to work with a extra node where you map user names to uids:
Database_App {
userNames {
"sebas,varela": "-3bSRmS4PHXUwsr7XbMBwgPozNfK2"
}
}
In this case the node essentially allows a user to claim their name. The advantage of this system is that the keys are automatically guaranteed to be unique on the server, no client-side code needed for that part.
You will want to: