-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.js
26 lines (24 loc) · 1.05 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
26
const config = require('./config/config.json');
const { Sequelize, DataTypes } = 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 || 3306,
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 conectado correctamente a la base de datos');
return db;
});