https://github.com/firmanjs/express-restfull-api-with-sequelize
express restfull api with sequelize and mysql
https://github.com/firmanjs/express-restfull-api-with-sequelize
Last synced: 10 months ago
JSON representation
express restfull api with sequelize and mysql
- Host: GitHub
- URL: https://github.com/firmanjs/express-restfull-api-with-sequelize
- Owner: firmanJS
- Created: 2020-09-23T04:28:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-03-07T06:31:13.000Z (about 5 years ago)
- Last Synced: 2025-03-28T09:11:46.125Z (about 1 year ago)
- Language: JavaScript
- Size: 72.3 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# express-restfull-api-with-sequelize
express restfull api with sequelize and mysql
# instalasi
ubah file konfigurasi database di `config/index` isi `username`, `password`, `database`, dan `host`
```js
require("dotenv").config()
const conf = {};
conf.environment = process.env.ENV;
conf.sequelize = {};
conf.sequelize.username = process.env.DB_USER
conf.sequelize.password = process.env.DB_PASS
conf.sequelize.database = process.env.DB_NAME
conf.sequelize.host = process.env.DB_HOST
conf.sequelize.dialect = 'mysql';
conf.sequelize.port = 3306;
conf.sequelize.define = {
charset: 'utf8mb4',
dialectOptions: {
collate: 'utf8mb4_unicode_ci'
}
}
conf.ROUND_SALT = 8;
module.exports = conf;
```
Install package
```sh
$ npm install
```
Generate model example
```
$ npx sequelize-cli model:generate --name Users --attributes username:string,fullname:string,email:string,password:string
```
Run Migration
```sh
$ npx sequelize-cli db:migrate
```
Generate example seeder
```sh
$ npx sequelize-cli seed:generate — name demo-user
```
Running seeder
```sh
$ npx sequelize-cli db:seed:all
```