-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
25 lines (23 loc) · 951 Bytes
/
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.json");
const { Sequelize } = require("sequelize");
const sequelize = new Sequelize(
process.env.MYSQL_DATABASE || config.development.database,
process.env.MYSQL_USER || config.development.username,
process.env.MYSQL_PASSWORD || config.development.password,
{
host: process.env.MYSQL_HOST || config.development.host,
port: process.env.MYSQL_PORT || config.development.port || "3307",
dialect: "mysql",
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;
});