aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRan Guin <[email protected]>2021-06-16 22:16:58 -0700
committerRan Guin <[email protected]>2021-06-16 22:16:58 -0700
commit2eff666f7b90ab0251a099d31495e72b9ae1f4ea (patch)
treedb4561c88b3c7059bbf1506f8b403824070742c9
parent0f7b673325b60b3cb7cbb9cab1a4580655762500 (diff)
downloadcoinos-server-2eff666f7b90ab0251a099d31495e72b9ae1f4ea.tar.gz
coinos-server-2eff666f7b90ab0251a099d31495e72b9ae1f4ea.zip
use knexfile for db connection settings
-rw-r--r--db/index.js26
1 files changed, 9 insertions, 17 deletions
diff --git a/db/index.js b/db/index.js
index e9a6052f..e612987b 100644
--- a/db/index.js
+++ b/db/index.js
@@ -1,26 +1,18 @@
const Sequelize = require("sequelize");
-const conf = config.db;
-const debug = require('debug')('test')
+const debug = require('debug')('debug');
-debug('DB connection: ', conf.host + ' : ' + conf.database + ' : ' + conf.user)
+const dbOptions = require('./../config/knexfile.js')[process.env.NODE_ENV || "development"]
-db = new Sequelize(conf.database, conf.user, conf.password, {
- host: conf.host,
- dialect: conf.dialect,
+db = new Sequelize(dbOptions.connection.database, dbOptions.connection.user, dbOptions.connection.password, {
+ host: dbOptions.connection.host,
+ dialect: "mariadb",
logging: false,
- dialectOptions: conf.dialectOptions
+ dialectOptions: { "multipleStatements": true, "timezone": "Etc/GMT+7" }
});
-debug('knex conf: ' + JSON.stringify(conf))
-knex = require('knex')({
- client: 'mysql2',
- connection: {
- user: conf.user,
- password: conf.password,
- database: conf.database,
- host: conf.host
- }
-})
+debug('knex dbOptions: ' + JSON.stringify(dbOptions))
+
+knex = require('knex')(dbOptions)
require("./models/accounts.js");
require("./models/codes.js");