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 14 – MongoDB API – Nathalie #489

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

Conversation

ohitsnathalie
Copy link

Copy link

@AntonellaMorittu AntonellaMorittu left a comment

Choose a reason for hiding this comment

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

Hi Nathalie, congrats deploying your first DB! Your code looks good on github, however I couldn't test the endpoint returning any data correctly, I left a comment as I suspect the issue is the env variable that needs to be passed to Render RESET_DATABASE=true in order to seed the db. Please doublecheck, thank you :)

const NetflixModel = mongoose.model("Netflix", netflixSchema)

// Set Seed
if (process.env.RESET_DATABASE) {

Choose a reason for hiding this comment

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

did you add the env to the hosting service settings? (Render) The DB is empty at the moment

Copy link
Author

Choose a reason for hiding this comment

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

Hi Antonella,
I checked again and fixed the bug. I saw, that I wrote Netflix instead of NetflixModel.
It should work now. Thank you :)

Copy link

@AntonellaMorittu AntonellaMorittu left a comment

Choose a reason for hiding this comment

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

Nice! Please bear in mind that your data is now having 2 ids, MongoDB assigns automatically an _id, so you can remove the show_id from your schema and update the code to find the _id:

const movie = await NetflixModel.findOne({
      _id: Number(id),
      type: "Movie",
    })

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.

2 participants