- As a user, I want to save movies from my search results to a list of my faves.
- As a user, I want to perform this action from the movie detail page.
- Install the new node modules needed for database access.
- Initialize sequelize for this project.
- Update the config file and create a database named
omdb
. - Create a
fave
model with two fields-title:string
andimdbid:string
- Run migrations.
- Require your model into the location of your routes.
- Modify your
detail.ejs
to include a form for adding this movie as a fave:
- This form should have a
POST
method, with an action of/faves
- It should contain two hidden fields containing the title and IMDB ID of this movie. These fields should be named the same as your model attribute names.
- Write your POST route for
/faves
:
- Use
req.body
to access body data from the form. - Use the fave model to save this data to your database. YOU WILL NEED TO REQUIRE THE MODEL TO USE IT.
- In the callback of your
create
, useres.redirect
to redirect to the GET route for your faves.
- Write your GET route for
/faves
:
- Use the fave model to get all faves from your database.
- In the callback, use
res.render
to render all your faves to a page namedfaves.ejs
(not provided).
- All content is licensed under a CC-BY-NC-SA 4.0 license.