node.js - Sequelize 'Dialect needs to be explicitly supplied as of v4.0.0'

标签 node.js error-handling sequelize.js

我需要在 node.js 环境中运行第三方应用程序,但 Sequelize 抛出“从 v4.0.0 开始需要显式提供方言” 我在这里找到了类似的主题 Dialect needs to be explicitly supplied as of v4.0.0但是 'export NODE_ENV=development' 不起作用,我找不到 Sequelize 配置文件。 我该如何解决这个错误?

代码如下:

const Sequelize = require('sequelize');

const scheme = require('./scheme');

const Op = Sequelize.Op;

const sequelize = new Sequelize(null, null, {

dialect: 'sqlite',
storage: 'db.sqlite3',

operatorsAliases: { $and: Op.and },

logging: false
});

scheme(sequelize);
sequelize.sync();

module.exports.sequelize = sequelize;
module.exports.models = sequelize.models;

最佳答案

您只需在初始化 sequelize 时提供方言;

const sequelize = new Sequelize('database', 'username', 'password', {
  host: 'localhost',
  dialect: // pick one of 'mysql','sqlite','postgres','mssql',
});

关于node.js - Sequelize 'Dialect needs to be explicitly supplied as of v4.0.0',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48397401/

相关文章:

javascript - 变量不会设置

node.js - 在 Visual Studio Code 中调试输出 nodejs

c# - ASP.NET MVC3中不同区域的自定义错误页面

node.js - 嵌套包含偏移和限制 Sequelize

sequelize.js - 在 Sequelize 6 中获取 instance._modelOptions

node.js - NodeJS Sequelize ORM db :seed:all drops tables from db

javascript - 无法为 VueJS + NodeJS 安装 Firebase

javascript - Node.js中是否有类似“get_meta_tags”的方法?

error-handling - Spring集成errorChannel在JUnit中没有消息

python - 如何不返回调用函数?