flame/db.js

24 lines
499 B
JavaScript
Raw Normal View History

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