-
src folder
- index.js (Server)
- /models
- /config
- /controller
- /utils
- /router
- /middlewares
- /services
-
Tests [future]
- Clone the repository in your local machine
- Execute the
npm run installin the Root Directory of the downloaded project - create a
.envfile and copy and paste the code from.env.sample - Run
npm i sequelize-clinpm i sequelizenpm i mysql2these command - Execute the
npx sequelize initcommand into root directory of the folder - Move
Modelsseedersmigrationsandconfiginside src folder - Change the
src/config/config.jsonaccording to below - inside the
src/configfolder create a new fileconfig.jsonand the copy and paste the following code and put the database name and password according to you
"development": {
"username": <YOUR_USER_NAME>,
"password": <YOUR_PASSWORD>,
"database": <YOUR_DATA_BASE_NAME>,
"host": "127.0.0.1",
"dialect": "mysql"
},
-
Once completed the above steps successfully then go to
srcroot Directory and executenpx sequelize db:create -
After performing the above execute
npx sequelize db:create -
crosscheck the databse has created or not
- Airline Management system
- Airplane Table (One Airplane can have different Flight) Airplane : Flight 1:N
- Flight Table (One flight can be attended by any of the Plane)
- Airport Table (One airport can have different flight) Airport:Flight 1:N
- City Table (One City can have different Airports) City:Airport 1:N
- run
npx sequelize model:generate --name <MODEL_NAME> --attributes <ATTRIBUTE_NAME:TYPE> - Exa
npx sequelize model:generate --name City --attributes name:String - result
New model was created at <ROOT>New model was created at <ROOT>
-
Till now it's not synched with our database
-
To make in synch with database run
npx sequelize db:migrate -
create city repository in
src/repository/city-repository.jsto interact with models and write logic to CRUD and all (repository layer is responsible for DB interaction) -
All the interaction from model will be completed from repository level.
-
Repository layer is communicationg to service layer to perform extra logic calculation.
-
Service Layer is communicating to controller and the business logic are written inside controller layer
-
Controller layer will hit the api inside /v1/index.js with corresponding routes.
-
For running MySql Server mysql -h localhost -P 3306 -u root -p -
or
mysql -u root -p
- Connection to postgres
postgress://[username]/[password]@[host]/[database_name]
- go to elephentSql (Provide 20 MB of free Data Storage) but unfortunetly they did't operates now (End of Life announcement Elephent SQL)
