var usernameEntered = self.textField.text!
var databaseReferenceQuery = DataService.ds.REF_USERS.queryOrderedByChild("username").queryEqualToValue(usernameEntered).observeSingleEventOfType(.Value,
withBlock: { (snapshot) in
if ( snapshot.value is NSNull ) {
} else {
print(snapshot.key)
print(snapshot.value.)
}
}, withCancelBlock: { (error) in
// An error occurred
})
}
This is what I've got.
My firebase database is set up like :
Users
20394802938lsjfkjaweli (the uid)
username: Bob
0skjflakjlkwjf93j09
username: Bobby
By running that query I'm searching through the usernames and checking to see if it equals what's entered into the text field.
When I do something like print(snap.value) I get "username: (whatever i put into the text field if it matches a username)
What I need is to be able to snag the user ID associated with that username.
Using snapshot.key provides me with "Users". How do I get one level below that?