Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Week 19: happy thoughts API #509

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jacquelinekellyhunt
Copy link

@jacquelinekellyhunt jacquelinekellyhunt commented Dec 22, 2024

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

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
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
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
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
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