mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 15:07:42 +02:00
24 lines
697 B
JavaScript
24 lines
697 B
JavaScript
const Sequelize = require('sequelize');
|
|
|
|
const database = new Sequelize(process.env.DATABASE_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;
|