Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes 4/3/25
Spring Cleaning
Added Comment functionality to the Social Media site
Added a like button for comments:
Updated the
comments.js
route file to include aPUT
route for liking comments (/likeComment/:id
).Added a
likeComment
method in thecommentsController
to increment thelikes
field in theComment
model usingfindByIdAndUpdate
.Updated the
post.ejs
file to include a like button for each comment, which sends aPUT
request to the server using themethod-override
middleware.Added a delete button for comments:
Updated the
comments.js
route file to include aDELETE
route for deleting comments (/deleteComment/:id
).Added a
deleteComment
method in thecommentsController
to find and delete a comment by its ID usingfindById
anddeleteOne
.Updated the
post.ejs
file to include a delete button for each comment, which sends aDELETE
request to the server using themethod-override
middleware.Ensured the
postId
is passed as a hidden input in the form to allow redirection back to the correct post page after deletion.Updated deleting comments when deleting posts:
deleteMany() is a mongoDB method that is used to delete multiple documents from a collection that match a specified filter. This allows for easy removal of comments when getting rid of a post.
Added some CSS to make comments nicer to look at.