Skip to content

Commit

Permalink
Delete post comments and the post itself
Browse files Browse the repository at this point in the history
  • Loading branch information
Codycody31 committed Oct 12, 2023
1 parent 8aef693 commit 83323a7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions backend/controllers/PostController.js
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,9 @@ router.delete("/:postId", authenticateJWT, async (req, res) => {
});
}

// Delete the post's comments
await Comment.deleteMany({ post: req.params.postId });

// Delete the post
await Post.deleteOne({ _id: req.params.postId });

Expand Down

0 comments on commit 83323a7

Please sign in to comment.