Can you help me solve this problem? I want to delete a specific message in the database.
My database looks like this:
• MESSAGES
••(childByAutoID XXXXXXXXX)
•••email: user1@gmail.com
•••message: hello there
•••timestamp: 329842938592
•
••(childByAutoID XXXXXXXXX)
•••email: user1@gmail.com
•••message: where are you?
•••timestamp: 872985042750
•
••(childByAutoID XXXXXXXXX)
•••email: user2@gmail.com
•••message: basketball?
•••timestamp: 845938459349
I tried using this code but it deletes the wrong post from the current user (user1).
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if (editingStyle == .delete) {
jobRequests.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .automatic)
if let email = Auth.auth().currentUser?.email {
Database.database().reference().child("MESSAGES").queryOrdered(byChild: "email").queryEqual(toValue: email).observeSingleEvent(of: .childAdded, with: { (snapshot) in
snapshot.ref.removeValue()
so how can i delete the message "where are you?" and its members.