Firebase snapshot.key not returning actual key?
Solution 1:
When you run a query at a location, the result will be a list of the matching children. Even if there is only a single matching item, the result will be a list of one child.
You're printing the key of all resulting children. Since there is no single result, the SDK prints the key of the location/collection that you queried: users
.
What you're likely looking for is to loop over the matching children and print their keys:
let query = usersRef.queryOrderedByChild("email").queryEqualToValue(email)
query.observeEventType(.Value, withBlock: { snapshot in
for child in snapshot.children {
print(child.key)
}
})