Practice What You Learned
Intro
Today your going to be using Mongoose, along with your knowledge of new, create and index routes to complete the below assignment. Today you:
| Created a Schema for a collection | | Created a model and save it | | found a specific model | | updated a model already in the database | | removed a model already in the database |
Goal
The goal of this lab is to add the ability to specify the airport that the flight is originating from; and a list (array) of destinations for the flight.
Styling is secondary, spend time on it only after the functionality has been implemented.
Exercises
-
Create a
destinationSchemathat will provide the structure for destination subdocuments with the following properties:Property Type Validations Default Value airportStringenumto include
'AUS', 'DAL', 'LAX', 'SAN' & 'SEA'n/a arrivalDaten/a n/a -
Add the following two additional properties to the
FlightModel:Property Type Validations Default Value airportStringenumto include
'AUS', 'DAL', 'LAX', 'SAN' & 'SEA''SAN' destinations[destinationSchema]n/a n/a - Modify the form for inputting a flight to add a
<select name="airport">element to include a value for the new flight document'sairportproperty. Ensure that there are<option>elements for the four allowable airport codes ('AUS', 'DAL', etc.). - Implement the following User Story:
AAU, when viewing the list of flights, I want to click on a "detail" link displayed next to each flight to view all of the properties for that flight (showview) - Implement the following User Story:
AAU, when viewing the details page (showview) for a flight, I want to be able to add a destination for that flight, including itsarrivaldate/time & one of the established airport codes - Implement the following User Story:
AAU, when viewing the details page (showview) for a flight, I want to see a list of that flight'sdestinations(airport&arrival)
Bonuses
- Sort the list of
destinationsfor a flight by thearrivaldate/time in ascending order. - Style the views.
- When adding a destination for a flight, exclude the airports listed in the
<select>that have already been used by other destinations and/or the flight'sairport.
