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

  1. Create a destinationSchema that will provide the structure for destination subdocuments with the following properties:

    Property Type Validations Default Value
    airport String enum to include
    'AUS', 'DAL', 'LAX', 'SAN' & 'SEA'
    n/a
    arrival Date n/a n/a
  2. Add the following two additional properties to the Flight Model:

    Property Type Validations Default Value
    airport String enum to include
    'AUS', 'DAL', 'LAX', 'SAN' & 'SEA'
    'SAN'
    destinations [destinationSchema] n/a n/a
  3. Modify the form for inputting a flight to add a <select name="airport"> element to include a value for the new flight document's airport property. Ensure that there are <option> elements for the four allowable airport codes ('AUS', 'DAL', etc.).
  4. 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 (show view)
  5. Implement the following User Story:
    AAU, when viewing the details page (show view) for a flight, I want to be able to add a destination for that flight, including its arrival date/time & one of the established airport codes
  6. Implement the following User Story:
    AAU, when viewing the details page (show view) for a flight, I want to see a list of that flight's destinations (airport & arrival)


Bonuses

  1. Sort the list of destinations for a flight by the arrival date/time in ascending order.
  2. Style the views.
  3. 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's airport.

Copyright © Per Scholas 2023