diff options
| author | Ran Guin <[email protected]> | 2021-06-16 22:16:58 -0700 |
|---|---|---|
| committer | Ran Guin <[email protected]> | 2021-06-16 22:16:58 -0700 |
| commit | 2eff666f7b90ab0251a099d31495e72b9ae1f4ea (patch) | |
| tree | db4561c88b3c7059bbf1506f8b403824070742c9 /db/index.js | |
| parent | 0f7b673325b60b3cb7cbb9cab1a4580655762500 (diff) | |
| download | coinos-server-2eff666f7b90ab0251a099d31495e72b9ae1f4ea.tar.gz coinos-server-2eff666f7b90ab0251a099d31495e72b9ae1f4ea.zip | |
use knexfile for db connection settings
Diffstat (limited to 'db/index.js')
| -rw-r--r-- | db/index.js | 26 |
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"); |
