Skip to content

Week 19: happy thoughts API#509

Open
jacquelinekellyhunt wants to merge 5 commits intoTechnigo:masterfrom
jacquelinekellyhunt:master
Open

Week 19: happy thoughts API#509
jacquelinekellyhunt wants to merge 5 commits intoTechnigo:masterfrom
jacquelinekellyhunt:master

Conversation

@jacquelinekellyhunt
Copy link
Copy Markdown

@jacquelinekellyhunt jacquelinekellyhunt commented Dec 22, 2024

@HIPPIEKICK HIPPIEKICK self-assigned this Jan 9, 2025
Copy link
Copy Markdown
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!

server.js Outdated
Comment on lines +38 to +44
// Example array of user references who have “liked” this thought
likedUsers: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
}
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice 👍

server.js Outdated

// Root endpoint - shows available endpoints in JSON
app.get('/', (req, res) => {
console.log('REQ.BODY =>', req.body);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No console.logs in production

server.js Outdated
Comment on lines +121 to +126
// Example toggle logic: if hearts is even, increment, otherwise decrement
if (thought.hearts % 2 === 0) {
thought.hearts += 1
} else {
thought.hearts -= 1
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What's the purpose of this? 👀

server.js Outdated
app.post('/thoughts/:id/like', async (req, res) => {
try {
const { id } = req.params
const thought = await Thought.findById(id)
Copy link
Copy Markdown
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? 🤔

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