module.exports = (sequelize, DataTypes) => {
const User = sequelize.define(
"User",
{
username: {
type: DataTypes.STRING,
unique: true
},
firstName: {
type: DataTypes.STRING
},
lastName: {
type: DataTypes.STRING
},
email: {
type: DataTypes.STRING
},
password: {
type: DataTypes.STRING
},
lastLogin: {
type: DataTypes.DATE
},
active: {
type: DataTypes.BOOLEAN
},
lastName: {
type: DataTypes.STRING
}
}, {
paranoid: true,
classMethods: {
associate: models => {
User.hasOne(models.User, {
as: "createdByUser"
})
User.hasOne(models.User, {
as: "updatedByUser"
})
}
}
}
)
return User
};
我希望在Postgres数据库中将一个字段称为createdByUser
,但它不存在。我做错了什么?
答案 0 :(得分:2)
解决方案是
require-dev
在新版Sequelize(4+)中,不需要--no-dev