Im trying to search for values past two ChildByAutoIDs.
See firebase structure:
The Value I'm using to search is "-M0p0kDIDU0v2nPXAgKN".
Heres my code:
func fetchBuyer(search: String, completion: @escaping (Error?) -> ()) {
let ref = Database.database().reference().child("posts")
let query = ref.queryOrdered(byChild: "id").queryStarting(atValue: search).queryEnding(atValue: "\(search)\\uf8ff")
query.observeSingleEvent(of: .value) { (snapshot) in
guard snapshot.exists() != false else {
print("failing to search")
return }
print("Search value is here!", snapshot.value!)
}
}
.
My goal is to grab the values under purchases: "-M0p0tihPq2b5-FFiPaK" and "-M0p17NP11K7MPndpin5".
But I keep getting the error "Failing to search"??
Im following an example on StackOverflow, but I still cant get it to work!
Please help!