mirror of
https://github.com/pawelmalak/flame.git
synced 2024-12-19 08:02:16 +03:00
25 lines
554 B
JavaScript
25 lines
554 B
JavaScript
|
const { Sequelize } = require('sequelize');
|
||
|
|
||
|
const sequelize = new Sequelize({
|
||
|
dialect: 'sqlite',
|
||
|
storage: './db.sqlite'
|
||
|
});
|
||
|
|
||
|
const connectDB = async () => {
|
||
|
try {
|
||
|
await sequelize.authenticate({ logging: false });
|
||
|
console.log('Connected to database'.cyan.underline);
|
||
|
await sequelize.sync({
|
||
|
// alter: true,
|
||
|
logging: false
|
||
|
});
|
||
|
console.log('All models were synced'.cyan.underline);
|
||
|
} catch (error) {
|
||
|
console.error('Unable to connect to the database:', error);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
connectDB,
|
||
|
sequelize
|
||
|
};
|