Created
May 19, 2021 06:53
-
-
Save magyarmelinda/84aca7480d700ea8222949253ae5d0bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Delete A Comment or A Thread | |
const deleteContent = (collection, id) => { | |
let toDelete = db.collection(collection).where(firebase.firestore.FieldPath.documentId(), '==', id); | |
toDelete.get().then(snapshot => { | |
snapshot.forEach(doc => { | |
const data = doc.data(); | |
if (firebase.auth().currentUser.uid == data.user) { | |
doc.ref.delete().then(() => { | |
(collection == 'threads') ? getThreads() : setUpComments(data.thread); | |
}); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment