Files
xiao/structures/PostgreSQL.js
T
Daniel Odendahl Jr 91a000b220 Move Things Around
2017-04-27 15:43:58 +00:00

21 lines
685 B
JavaScript

const Sequelize = require('sequelize');
const database = new Sequelize(process.env.DATABASE_URL, { logging: false });
module.exports = class Database {
static get db() {
return database;
}
start() {
database.authenticate()
.then(() => console.log('[Database] Connection has been established successfully.'))
.then(() => console.log('[Database] Synchronizing...'))
.then(() => database.sync()
.then(() => console.log('[Database] Synchronizing complete!'))
.catch(err => console.error(`[Database] Error synchronizing: ${err}`))
)
.then(() => console.log('[Database] Ready!'))
.catch(err => console.error(`[Database] Unable to connect: ${err}`));
}
};