Menghubungkan Sequelize ke MySQL

Buat File config.db pada folder config dan isi dengan script berikut:

// folder-project/config/config.js

const Sequelize = require('sequelize'); 

const sequelize = new Sequelize('db_product', 'root', '', {
  host: 'localhost',
  dialect: 'mysql',
  pool: {
    max: 5,
    min: 0,
    idle: 10000
  }
});

sequelize.authenticate()
  .then(() => {
    console.log('Connection has been established successfully.');
  })
  .catch(err => {
    console.error('Unable to connect to the database:', err);
  });

module.exports = sequelize;

results matching ""

    No results matching ""