Answers for "how to initialize sequelize in node js"

4

command to make a new model in sequelize

npx sequelize-cli model:generate --name User --attributes firstName:string,lastName:string,email:string
Posted by: Guest on May-20-2021
0

sequelize init connection set up nodejs node

const Sequelize = require('sequelize');

const path = 'mysql://user12:12user@localhost:3306/testdb';
const sequelize = new Sequelize(path, { operatorsAliases: false });

sequelize.authenticate().then(() => {
  console.log('Connection established successfully.');
}).catch(err => {
  console.error('Unable to connect to the database:', err);
}).finally(() => {
  sequelize.close();
});
Posted by: Guest on May-19-2021

Code answers related to "how to initialize sequelize in node js"

Browse Popular Code Answers by Language