Skip to content

Instantly share code, notes, and snippets.

@magyarmelinda
Created May 19, 2021 06:53
Show Gist options
  • Save magyarmelinda/84aca7480d700ea8222949253ae5d0bd to your computer and use it in GitHub Desktop.
Save magyarmelinda/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