当用户点击按钮时,我希望能够使用一个调用删除单独的父节点中的2个值。目前,我刚刚将第二个数据库删除调用放置在第一个调用的完成块中。
guard let uid = Auth.auth().currentUser?.uid else {return}
guard let convoId = conversation?.conversationId else {return}
let ref = Database.database().reference()
let leaveChatAction = UIAlertAction(title: "Leave", style: .destructive) { (action) in
ref.child("users").child(uid).child("conversations").child(convoId).removeValue(completionBlock: { (error, ref) in
if let error = error {
print ("Couldn't delete convo ID from users node:", error)
}
ref.child("conversation_users").child(convoId).child(uid).removeValue(completionBlock: { (error, ref) in
if let error = error {
print ("Couldn't delete userID from convo node:", error)
}
self.navigationController?.popViewController(animated: true)
})
})
}