Example of Express and MongoDB to make a simple API
yarn dev
=> localhost:7000
- List movies:
GET /movies
- Create sample movies:
GET /setup
- Add
yearReleased
(Number),description
,rating
- Refactor to place all movie routes into
routes/movies.js
usingexpress.Router()
- You can create using
new Movie(doc).save()
orMovie.create(doc)
- You can update using
Movie.findByIdAndUpdate(id, newDoc)
- Create movie:
POST /movies
- Update movie:
PUT /movies/:id
- Delete movie:
DELETE /movies/:id
- Make sure you use the correct status code (e.g.
201
for create)
- Create another schema + model called
Person
- Add
actors
,crew
,writers
,directors
using references: https://alexanderzeitler.com/articles/mongoose-referencing-schema-in-properties-and-arrays/
- Lists movies
- Create a movie using a form
- Update a movie
- Delete a movie
- Filter movies by year