-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
25 lines (23 loc) · 1.01 KB
/
db.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const config = require('./config/config');
const { Sequelize } = require('sequelize');
const sequelize = new Sequelize(
process.env.DB_NAME || config.development.database,
process.env.DB_USER || config.development.username,
process.env.DB_PASSWORD || config.development.password,
{
host: process.env.DB_HOST || config.development.host,
port: process.env.DB_PORT || config.development.port || '3306',
dialect: process.env.DB_DIALECT || config.development.dialect,
operatorAliases: false,
pool: {
max: 5, //maximum number of connection in pool
min: 0, //minimum number of connection in pool
acquire: 30000, //maximum time, in milliseconds, that a connection can be idle before being released
idle: 10000, // maximum time, in milliseconds, that pool will try to get connection before throwing error
},
}
);
module.exports = sequelize.authenticate().then((db) => {
console.log('MYSQL connected');
return db;
});