sequelize

Sequelize | 0. 初始化

2021-01-06  本文已影响0人  ShadowFieldEric

安装

npm install --save sequelize

初始化使用

const { Sequelize, Model, DataTypes } = require('sequelize');

const sequelize = new Sequelize('db_stu', 'db_username', 'db_password', {
  host: '127.0.0.1',
  dialect: 'mysql',
  pool: {
    max: 50,
    min: 0,
    idle: 5000
  }
});

测试连接

sequelize.authenticate()

(async () => {
  try {
    await sequelize.authenticate();
    console.log('Connection has been established successfully.');
  } catch (error) {
    console.error('Unable to connect to the database:', error);
  }
})()
上一篇下一篇

猜你喜欢

热点阅读