flame/db.js

27 lines
552 B
JavaScript
Raw Normal View History

const { Sequelize } = require('sequelize');
const sequelize = new Sequelize({
dialect: 'sqlite',
2021-06-05 16:48:43 +03:00
storage: './data/db.sqlite',
logging: false
});
const connectDB = async () => {
try {
await sequelize.authenticate({ logging: false });
console.log('Connected to database');
2021-06-05 16:48:43 +03:00
await sequelize.sync({
// alter: true,
logging: false
});
console.log('All models were synced');
} catch (error) {
console.error('Unable to connect to the database:', error);
}
}
module.exports = {
connectDB,
sequelize
};