mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
23 lines
702 B
JavaScript
23 lines
702 B
JavaScript
const Sequelize = require('sequelize');
|
|
const database = new Sequelize(process.env.DATABASE_URL, { logging: false });
|
|
|
|
class Database {
|
|
static get db() {
|
|
return database;
|
|
}
|
|
|
|
static 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}`));
|
|
}
|
|
}
|
|
|
|
module.exports = Database;
|