Skip to content

happy-thoughts-api#500

Open
gittebe wants to merge 26 commits intoTechnigo:masterfrom
gittebe:master
Open

happy-thoughts-api#500
gittebe wants to merge 26 commits intoTechnigo:masterfrom
gittebe:master

Conversation

@gittebe
Copy link

@gittebe gittebe commented Dec 19, 2024

Copy link
Contributor

@HIPPIEKICK HIPPIEKICK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use mongoose methods when you can, otherwise - good job!

app.post("/thoughts/:id/like", async (req, res) => {
try {
const {id} = req.params
const thought = await Thought.findById(id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use findByIdAndUpdate for updating hearts directly instead of fetching, modifying, and saving? 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you :) I changed it

server.js Outdated
Comment on lines +96 to +100
if (thought.hearts %2=== 0) {
thought.hearts+=1
} else {
thought.hearts -=1
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? 😅

@gittebe gittebe requested a review from HIPPIEKICK January 7, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants