Create db module
This commit is contained in:
commit
e106a10374
14
config/index.js
Normal file
14
config/index.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
module.exports = {
|
||||||
|
HOST: process.env.PG_HOST,
|
||||||
|
USER: process.env.PG_USER,
|
||||||
|
PASSWORD: process.env.PG_PASS,
|
||||||
|
DB: process.env.PG_DB,
|
||||||
|
PORT: process.env.PG_PORT,
|
||||||
|
dialect: "postgres",
|
||||||
|
pool: {
|
||||||
|
max: 5,
|
||||||
|
min: 0,
|
||||||
|
acquire: 30000,
|
||||||
|
idle: 10000
|
||||||
|
}
|
||||||
|
}
|
||||||
31
index.js
Normal file
31
index.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
const config = require("./config");
|
||||||
|
|
||||||
|
const Sequelize = require("sequelize");
|
||||||
|
const sequelize = new Sequelize(
|
||||||
|
dbConfig.DB,
|
||||||
|
dbConfig.USER,
|
||||||
|
dbConfig.PASSWORD,
|
||||||
|
{
|
||||||
|
host: dbConfig.HOST,
|
||||||
|
dialect: dbConfig.dialect,
|
||||||
|
port: dbConfig.PORT,
|
||||||
|
pool: {
|
||||||
|
max: dbConfig.pool.max,
|
||||||
|
min: dbConfig.pool.min,
|
||||||
|
aqcuire: dbConfig.pool.acquire,
|
||||||
|
idle: dbConfig.pool.idle
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
const db = {};
|
||||||
|
|
||||||
|
db.Sequelize = Sequelize;
|
||||||
|
db.sequelize = sequelize;
|
||||||
|
|
||||||
|
db.intent = require("./intent.model")(sequelize, Sequelize);
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
db
|
||||||
|
};
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user