{ Mongo and Mongoose Exercises. }

Let's once again rebuild our previous example using a shopping list, but this time we will not be using an array to store our data. Instead, we will be using a Mongo database! The resource we will be working with once again is item.

The application should have one model for Item and each item should have:

  • a unique id
  • a name which should be a string
  • a quantity which should be a number

The application should have the following routes:

  • GET /items to show all items in the shopping list
  • GET /items/new to show a form for creating a new item
  • GET /items/:id to show a single item
  • GET /items/:id/edit to show a form for editing a item
  • POST /items to create an item when a form is submitted
  • PATCH /items/:id to edit an item when a form is submitted
  • DELETE /items/:id to delete an item when a form is submitted

Bonus

  1. Create a route for GET /items/search which allows a user to search for items in the shopping list.
  2. Create a route for DELETE /items which allows a user to remove all the items in the shopping list.
  3. Create another model called User, which should have a reference to Item. A user should be able to have their own list of items and have full CRUD over items in their list.

When you're ready, move on to Introduction to Heroku

Continue

Creative Commons License