-
Notifications
You must be signed in to change notification settings - Fork 498
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :)
There was a problem hiding this 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",
})
Render link
https://mongo-api-netflixdata.onrender.com