I am trying to execute a Firebase request and does not seem to work properly. I am trying to access the name of the school that I have in the Firebase database. The database is as follows:
Schools { Random School Name { schoolLocation: Random Location uid: random UUID } }
If I use the following code to get information about the "Random School Name", I get a snapshot with a zero value:
databaseReference.child("Schools").queryEqualToValue("Random School Name").observeSingleEventOfType(.Value, withBlock: { (snapshot: FIRDataSnapshot) in print(snapshot) }) { (error: NSError) in self.displayError("Search Failed", message: "We couldn't search for that - \(error.code): \(error.localizedDescription)") }
If I use this line of code, the query returns me the name of the school, as expected. I want to track if there is an error using observeSingleEventOfType :
let query = databaseReference.child("Schools").queryEqualToValue("Florida Institute of Technology") print(query)
Why is this not working?
ios xcode swift firebase firebase-database
Dan levy
source share