I have an structure like this in "/users"
{ "aaa@aaa-com":{ "email":"[email protected]", "name": "Joseph", }, "asd@asd-com": { "email": "[email protected]", "name": "Erik" } } I made a query to access the child that has the email "[email protected]" :
usersRef.queryOrderedByChild("email").queryEqualToValue("[email protected]") .observeEventType(.Value, withBlock: { snapshot in if snapshot.exists() { print("user exists") } else if !snapshot.exists(){ print("user doesn't exists") } If I print(snapshot) I get the console output in xcode:
Snap (users) { "aaa@aaa-com" = { email = "[email protected]"; name = "Joseph"; }; } I'm trying to find some way to get the name of the user after doing this query, but I didn't find the way to do it. I tried with:
print(snapshot.value.objectForKey("name")) print(snapshot.value.valueForKey("name")) but I get nil in both.
Do you guys know how to get the name value?
Thanks in advance!!
("aaa@aaa-com")instead of("[email protected]")? I think that's why is not finding it