Giter Club home page Giter Club logo

lab-node-express-mongo-modeling's Introduction

Mongoose Modeling – Embedded & Referenced Documents

Introduction

Note: This can be a pair programming activity or done independently.

To practice using Mongoose, we will design a small data persisting application to keep track of airport data with different models: Airport, Terminal, Flight, and Passenger. You will have to write the models and then hard code data in app.js file according to the requirements below.
Since we're not worried about Express or views in this activity, log the results of your data persistence in the console when the file is executed - with node app.js - so we know what's being saved.

Exercise

Requirements

  • Create an Express application with four models: Airport, Terminal, Flight, and Passenger

  • Include Mongoose and create embedded and referenced models:

    • Airport
      • Name(String)
      • country(String)
      • terminals(Array of embedded Terminal Objects)
      • opened(Date)
    • Terminal
      • name(String)
      • flights(Array of referenced Flight Objects)
      • capacity(Number)
    • Flight
      • from(String)
      • to(String)
      • airline(String)
      • passengers(Array of referenced Passenger Objects)
    • Passenger
      • firstName(String)
      • lastName (String)
      • dob (Date)
  • Create the following data in app.js:

    • A flight from CDG France to JFK New-York, USA on American Airlines with no passengers.
      Assign this object to variable "flight1"

    • A second flight from Heathrow UK to JFK New-York, USA on British Airways with no passengers.
      Assign this object to variable "flight2"

    • An airport called JFK in the USA opened on a random date in 1990. Assign this object to variable "airport1"

    • A terminal called Terminal 1 that is pushed to airport1 with a capacity of 234324 and two flights: flight1 and flight2

  • Save and console.log all the objects and their children in the console - you should see all objects when node app.js is executed.

Starter code

No starter code for this app, create it from scratch !

Deliverable

The app's folder structure should look like this:

├── app.js
├── models
│   ├── airport.js
│   ├── flight.js
│   ├── passenger.js
│   └── terminal.js
├── node_modules
└── package.json

You should see all your objects when logged in the console when node app.js is executed.

Additional Resources

lab-node-express-mongo-modeling's People

Contributors

dshcheung avatar tan-sam avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.