Ajout de la base de données MySQL

This commit is contained in:
Rampeur
2025-08-13 21:51:07 +02:00
parent be44e4fdf0
commit 49b1a3f6b3
35 changed files with 1579 additions and 37 deletions
+43
View File
@@ -0,0 +1,43 @@
const { Sequelize } = require('sequelize');
const Op = Sequelize.Op;
const sequelize = new Sequelize(
process.env.MYSQL_DBNAME,
process.env.MYSQL_DBUSER,
process.env.MYSQL_DBPASS,
{
host: process.env.MYSQL_DBHOST,
port: process.env.MYSQL_DBPORT,
dialect: process.env.MYSQL_DBTYPE,
$like: Op.like,
$not: Op.not,
timezone: '+02:00',
define: {
charset: 'utf8mb4',
collate: 'utf8mb4_general_ci',
underscored: false,
freezeTableName: true,
},
pool: {
//explain this line of code? this means that the connection pool will have a minimum of 0 connections and a maximum of 5 connections
min: 0,
max: 5,
},
logQueryParameters: process.env.APP_ENV === 'development', // this line of code will log the query parameters if the environment is development
benchmark: true,
});
/*
const checkConnection = async () => {
try {
await sequelize.authenticate();
console.log(`DB Connected`.cyan.underline.bold);
} catch (error) {
console.error("Unable to connect to the database:".red.bold, error);
}
};
checkConnection();
*/
module.exports = sequelize;