This Object Relational Mapping project, using :
- Postgres 13 for DBSM
- Express JS
-
npm init -y
at your directory project -
install
npm i sequelize pg
to install adapter than make Node Js can use Postgres -
install
npm i -D sequelize-cli
this contain command for configuration Postgres
nb: usenpx sequenlize
to see all command -
npx sequelize init
after install those modules, in project directory, there are some new folder -
go to
config.json
at config directory and fill the development configuration
nb: username default must be postgres if you not change it.
EXAMPLE :
"development": {
"username": "postgres",
"password": "password", use your password when setup postgres
"database": "database_sequelize", name your database
"host": "localhost",
"dialect": "postgres" because use postgres
}
npx sequenlize db:create
to execute the configuration
nb: usenpx sequenlize
to see all command
and from here the database is ready, for this case the name of the database is database_sequelize
npx sequelize db:migrate
npx sequelize model:generate --name Article --attributes title:string,body:text,approved:boolean
this for make the table in the database- finally you're ready to try it by your self.
- clone this project
npm i
for install all module that used in this projectnpm start
to start this project
this is for the API Collection using POSTMAN https://www.getpostman.com/collections/95ea54f9d037bca9bf6d