Skip to content

Instantly share code, notes, and snippets.

@m3l1nd4
Created May 19, 2021 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m3l1nd4/84aca7480d700ea8222949253ae5d0bd to your computer and use it in GitHub Desktop.
Save m3l1nd4/84aca7480d700ea8222949253ae5d0bd to your computer and use it in GitHub Desktop.
// 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