我当前在服务器端设置NodeJS
,ExpressJS
,Sequelize
和PostgresSQL
我的代码设置如下:-
我的config/config.js
文件中有以下内容
username: "Eexpress-mvp-dbuser",
password: "123",
database: "mvp-db",
host: "127.0.0.1",
dialect: "postgress",
port: 5432,
operatorsAliases: false
在我的迁移文件中,我设置了以下代码
up: (queryInterface, Sequelize) => {
return queryInterface.createTable("Leads", {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
email: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: (queryInterface, Sequelize) => {
return queryInterface.dropTable("Leads");
}
};```
Sequelize CLI [Node: 8.11.3, CLI: 5.5.0, ORM: 5.12.3]
Loaded configuration file "config\config.js".
ERROR: Dialect needs to be explicitly supplied as of v4.0.0
答案 0 :(得分:0)
您的方言名称有误:
使用dialect: "postgres"
代替dialect: "postgress"
还请确保安装以下依赖项:
npm install pg --save
npm install pg-hstore --save
最后,您需要创建一个数据库。 Sequelize不能满足您的需求