如何基于来自另一个节点的数据来获取数据?在下面的示例中,我希望获取所有fatherName = John的folderID,然后对于每个folderID,在Fetch table数组中获取相应的数组。
func fetchData(completion: @escaping ([Fetch])->()) {
let currentUser = Auth.auth().currentUser!
let postRef = self.databaseRef.child("father").queryOrdered(byChild: "fatherName").queryEqual(toValue: "John")
postRef.observe(.value, with: { (snapshot) in
var fatherArray = [Father]()
var followArray = [Fetch]()
for topic in snapshot.children {
let fatherName = Father(snapshot: topic as? DataSnapshot)
fatherArray.append(fatherName)
}
//for each followerId in fatherArray, retrieve the snapshot (not sure how to do this part)
completion(followArray)
}) { (error) in
print(error.localizedDescription)
}
}