Idk if this will work, but may as well try

This commit is contained in:
Daniel Odendahl Jr
2017-04-27 01:43:14 +00:00
parent 9c4cb0b738
commit c9a39c4d44
5 changed files with 270 additions and 6 deletions
+23
View File
@@ -0,0 +1,23 @@
const Sequelize = require('sequelize');
const database = new Sequelize(process.env.DB_URL, { logging: false });
class Database {
static get db() {
return database;
}
start() {
database.authenticate()
.then(() => console.log('Connection to database has been established successfully.'))
.then(() => console.log('Synchronizing database...'))
.then(() => database.sync()
.then(() => console.log('Synchronizing database done!'))
.catch(error => console.error(`Error synchronizing the database: ${error}`))
)
.then(() => console.log('Ready to rock!'))
.catch(err => console.error(`Unable to connect to the database: ${err}`));
}
}
module.exports = Database;