解决 (node:779) [SEQUELIZE0002] DeprecationWarning: The logging-option should be either a function ...

一、问题


Node 控制台报错:
(node:779) [SEQUELIZE0002] DeprecationWarning: The logging-option should be either a function or false. Default: console.log


二、解决


在 sequelize 初始化时,有个 logging 参数,用来控制控制台的原生 SQL 输出:

const sequelize = new Sequelize(dbName, user, password, {
  dialect: 'mysql',
  host,
  port,
  logging: true, // 这里
  timezone: '+08:00',
  define: {
    paranoid: true,
    underscored: true // 驼峰式命名改为下划线
  }
});

报错的原因就是:logging 属性默认参数是 console.log,并且只能设置成:false 或 Function,
删除这条配置,问题解决,并且不影响控制台输出。

你可能感兴趣的:(解决 (node:779) [SEQUELIZE0002] DeprecationWarning: The logging-option should be either a function ...)