Подключение Sequelize к БД

Подключение к БД с Sequelize осуществляется следующим образом:

const Sequelize = require('sequelize');

const sequelize = new Sequelize({
    host: 'localhost', // host of the database
    database: 'test_db', // name of the DB to connect
    dialect: 'postgres', // DB dialect, one of 'mysql' | 'mariadb' | 'postgres' | 'mssql'
    username: 'username', // DB user which will be used for connection to DB
    password: 'password', // DB user's password
});

sequelize.authenticate() // connect to DB & authenticate DB user
    .then(() => console.log('Connection to DB was established'))
    .catch((err) => console.log('Error during connection to DB', err))
;

Last updated