Assignment 2 - MongoDB
Assignment 2 - MongoDB
Instructions
In this assignment, you will continue your journey with MongoDB and Mongoose. You will
then create two new schemas for promotions and leadership, and then extend the
Express REST API server to support the /promotions and the /leaders REST API end
points.
Assignment Overview
At the end of this assignment you would have completed the following three tasks:
Implement a REST API to support the /leaders endpoint, and the /leaders/:leaderId
endpoint enabling the interaction with the MongoDB database
Assignment Requirements
Task 1
You are given the following example of a promotion document. You will now create the
Promotions schema and model to support the document:
"image": "images/buffet.png",
"label": "New",
"price": "19.99",
"featured": false
}
Note in particular that the label and price fields should be implemented the same way as
you did for the Dishes schema and model. The Promotions schema and model should be
defined in a file named promotions.js.
Next, extend the promoRouter.js to enable the interaction with the MongoDB database to
fetch, insert, update and delete information.
Task 2
You are given the following example of a leadership document. You will now create the
Leaders schema and model to support the document:
"image": "images/alberto.png",
"abbr": "CEO",
"featured": false
The Leaders schema and model should be defined in a file named leaders.js.
Next, extend the leaderRouter.js to enable the interaction with the MongoDB database to
fetch, insert, update and delete information.
Review criteria
Upon completion of the assignment, your submission will be reviewed based on the
following criteria:
Task 1
The Promotions schema and model correctly supports all the fields as per the
example document given above
The label field is set to an empty string by default
Task 2
The Leaders schema and model correctly supports all the fields as per the example
document given above.
The REST API endpoints /leaders and /leaders/:leaderId are implemented to interact with
the MongoDB database