我可以获取所有数据,但是不知道如何进入节点内部 并获取值。这是我要获取所有数据的数据库结构
func fetchData(){
ref = Database.database().reference()
let userid = Auth.auth().currentUser?.uid
ref.child(Constants.NODE_MAINTENANCE).child(userid!).child(Constants.NODE_MAINTENANCE_DATE).child(self.lastMaintenanceDateLbl.text ?? "").observe(DataEventType.value) { (snap) in
guard snap.exists()
else {
print("no data found at this date")
AppUtils.showAlert(title: "Alert", message: "No data found at this date!", viewController: self)
return}
// let maintenanceType = snapshot.value as? [String] ?? [""]
// print(maintenanceType)
if let snapshot = snap.children.allObjects as? [DataSnapshot]{
for snap in snapshot{
let maintenanceType = snap.value as? [String:Any]
for type in (maintenanceType?.values)!{
print(type)
}
}
}
}