diff options
Diffstat (limited to 'lib/models/index.js')
-rw-r--r-- | lib/models/index.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/models/index.js b/lib/models/index.js index d52f5508..e83956e5 100644 --- a/lib/models/index.js +++ b/lib/models/index.js @@ -13,10 +13,25 @@ var dbconfig = config.db; dbconfig.logging = config.debug ? logger.info : false; var sequelize = null; -if (dbconfig.hasOwnProperty('username') || dbconfig.hasOwnProperty('password')) - sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig); + +// Heroku specific +if (config.dburl) + sequelize = new Sequelize(config.dburl, dbconfig); else - sequelize = new Sequelize(dbconfig.database, dbconfig); + sequelize = new Sequelize(dbconfig.database, dbconfig.username, dbconfig.password, dbconfig); + +// [Postgres] Handling NULL bytes +// https://github.com/sequelize/sequelize/issues/6485 +function stripNullByte(value) { + return value ? value.replace(/\u0000/g, "") : value; +} +sequelize.stripNullByte = stripNullByte; + +function processData(data, _default, process) { + if (data === undefined) return data; + else return data === null ? _default : (process ? process(data) : data); +} +sequelize.processData = processData; var db = {}; |