简体   繁体   中英

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

我的firebase数据的示例图像

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 (ie 7542 in the example above, but I want to search the domain, "iautb.ac.ir").

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM