I am new to Firebase and Swift , and I am having some problems when it comes to queries. So, there are two main things that I would like to do:
- Request my users and find only those that contain a specific string in their name (or email address), and add them to the array.
- Get all my users and add them to the array.
The relevant part of my data for this question looks like this: 
As you can see, I use simplelogin Firebase (later I would also add Facebook to login), and I save my users by their uid.
Part of my rules file is as follows:
"registered_users": { ".read": true, ".write": true, ".indexOn": ["name"] }
Therefore, everyone should have access to this part of my data for reading and writing.
I also read the “Data Extraction” part of the iOS Firebase Guide on my website, and in accordance with this guide, my code to get all usernames and email addresses should work, at least I think so. But this is not so. Here is my code:
func getUsersFromFirebase() { let registeredUserRef = firebaseRef.childByAppendingPath("registered_users") registeredUserRef.queryOrderedByChild("name").observeSingleEventOfType(.Value, withBlock: { snapshot in if let email = snapshot.value["email"] as? String { println("\(snapshot.key) has Email: \(email)") } if let name = snapshot.value["name"] as? String { println("\(snapshot.key) has Name: \(name)") } }) }
I noticed that in the firebase manual they always used the ChildAdded type, not the value, but for me the value makes more sense. The result with the value is nothing, and the output from ChildAdded is only one user, namely the one that is registered right now.
So my questions are:
- Can I execute this query with my current data structure or do I need to get rid of user stories by their uid?
- If so, how do I change the code to make it work?
- If not, what would be the best way to store my users and make a query by name possible?
- How can I request, for example, to "collect" and get only the user simplelogin: 1 (Max Mustermann)?
I hope my description is quite detailed. Thanks in advance for your help.
Addition
It is strange that the manual "Data extraction" says that it is possible to query and sort the following data by height.
Data:

Request Code: 
And isn't that what I intend to do?