When a user taps a button I want to be able to delete 2 values in separate parent nodes using a single call. At the moment, I've just placed the 2nd database delete call within the completion block of the 1st call.
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)
})
})
}