0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00
ghost/core/server/data/db/connection.js
kirrg001 8115d83782 🔥 remove postgres support
refs #1333, refs #5878, refs #5321
2016-09-20 15:59:34 +01:00

27 lines
745 B
JavaScript

var knex = require('knex'),
config = require('../../config'),
knexInstance;
// @TODO:
// - if you require this file before config file was loaded,
// - then this file is cached and you have no chance to connect to the db anymore
// - bring dynamic into this file (db.connect())
function configure(dbConfig) {
var client = dbConfig.client;
if (client === 'sqlite3') {
dbConfig.useNullAsDefault = dbConfig.useNullAsDefault || false;
}
if (client === 'mysql') {
dbConfig.connection.timezone = 'UTC';
}
return dbConfig;
}
if (!knexInstance && config.get('database') && config.get('database').client) {
knexInstance = knex(configure(config.get('database')));
}
module.exports = knexInstance;