I'm trying to get the key of a node based on the child. Here's my structure
Code:
RESTAURANTS
KTNfWKLD0isCsrpys
name: “McDonalds”
loc: “LA”
KTNfWILD0iIkLLekc
name: “KFC”
loc: “LV”
Code:
FIRDatabase.database().reference().child("RESTAURANTS").queryOrderedByChild("name").queryEqualToValue("McDonalds").observeEventType(.Value, withBlock: { (snapshot) in
print(snapshot.key)
}, withCancelBlock: nil)
How can I get the key of "McDonalds" in a query?