📜  sequelize init 连接设置 nodejs 节点 - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:44.586000             🧑  作者: Mango

代码示例1
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();
});