Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase: Swift - Query value in child node without knowing the parent key

Example image of my firebase data

I have a firebase database which I have imported a list of approx. 8200 Universities with the details seen above.

I want to be able to enter an email address into a text field then query the "domain" part of this JSON. My issue is I need to query all the domains in the list of 8000, however I do not know how to search domain ad I do not have the "7542" to use a childByAppendingPath.

So I have a reference to "universities" but I need to be able to query "domain" without knowing the parent key (i.e. 7542 in the example above, but I want to search the domain, "iautb.ac.ir").

like image 330
Dom Bryan Avatar asked Feb 29 '16 16:02

Dom Bryan


1 Answers

You need to create a reference and Query that reference, check this link to find more about how to retrieve data from firebase.

Basically you need to do something like this

let myRef = Firebase(url: "https://your.firebaseio.com/universities")
let query = myRef.queryOrderedByChild("domain").queryEqualToValue("yourDomainSearchValue")

and then observe the events you need to on your query

like image 93
Francisco Medina Avatar answered Nov 20 '22 20:11

Francisco Medina