From 74c1da4536285593f3172f8be6a22ad300f73348 Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Mon, 12 Dec 2016 10:18:12 +0800 Subject: Simplify output with sequelize database argument --- lib/models/index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/models') diff --git a/lib/models/index.js b/lib/models/index.js index 3b49d459..60eedf61 100644 --- a/lib/models/index.js +++ b/lib/models/index.js @@ -11,7 +11,13 @@ var logger = require("../logger.js"); var dbconfig = config.db; dbconfig.logging = config.debug ? logger.info : false; -var sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig); + +var sequelize; +if (typeof dbconfig.username === 'undefined' && typeof dbconfig.password === 'undefined') { + sequelize = new Sequelize(dbconfig.database, dbconfig); +} else { + sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig); +} var db = {}; @@ -34,4 +40,4 @@ Object.keys(db).forEach(function (modelName) { db.sequelize = sequelize; db.Sequelize = Sequelize; -module.exports = db; \ No newline at end of file +module.exports = db; -- cgit v1.2.3