-
- All the middlewares will be kept here only
-
- models are to structure how our table be look like
-
- repository role is to interact with the database directly, no one else will interact with DB directly
-
- All the routes will be kept here
-
- Having a sepearte service folder goal is to keep sepearte all the buisness logic
-
- Role of controller is to get the Requests pass it to backend , backend proccess and thus passes res to the frontend
-
- this is for database migration (sequelize)
-
- to put some starting data in db
- clone the project on your local
- Execute
npm install
on the same path as of your root directory of the downloaded project - Create a
.env
file in the root directory and add the following environment variable- PORT=3000
- Indide the
src/config
folde create a new fileconfig.json
and add the following piece of json
{
"development": {
"username": <YOUR_DB_LOGIN_NAME>,
"password": <YOUR_DB_PASSWORD>,
"database": "Flights_Search_DB_DEV",
"host": "127.0.0.1",
"dialect": "mysql"
}
}
- Once you have added your db config as listed above , go to the src folder from your terminal and execute
npx sequelize db:create
and then executenpx sequelize db:migrate
-
Airplane Table
-
Flight
-
Airport
-
City
-
A flight belongs to an airplance but one can be used in muliple flights
-
A city has many airports but one airport belogs to a city
-
One airport can have many flights , but a flight belongs to one aiport
Relationship-> city has many airports and Airport belongs to a city (one to many)
npx sequelize model:generate --name Airport --attributes name:String,address:String,cityId:integer
npx sequelize db:migrate
- mysql -u root -p
- show databases
- USE databaseName;
- show tables
- SELECT * FROM tableName