gpt4 book ai didi

Node.js、sequelize 和 Unknown 专栏

转载 作者:搜寻专家 更新时间:2023-11-01 00:30:07 27 4
gpt4 key购买 nike

我读过这个类似的问题: Sequelize Unknown column '*.createdAt' in 'field list'

但解决方案对我不起作用!为什么?这是我的代码:

 var User = sequelize.define("User", {
id: {
type: DataTypes.UUID,
primaryKey: true
},
cognome: DataTypes.STRING,
nome: DataTypes.STRING,
email: DataTypes.STRING,
password: DataTypes.TEXT,
stato: DataTypes.INTEGER,
ruolo: DataTypes.INTEGER
}, {
freezeTableName: true
}, {
timestamps: false
});

错误是:

Executing (default): SELECT `id`, `cognome`, `nome`, `email`, `data_nascita`, `password`, `cellulare`, `stato`, `blacklist`, `createdAt`, `updatedAt` FROM `Candidato` AS `Candidato`;
Unhandled rejection SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column 'createdAt' in 'field list'

最佳答案

与其将 { timestamps: false } 作为 Sequelize.define 调用的附加参数传递,不如使用相应的属性扩展现有的(第三个)参数:

var User = sequelize.define("User", {
// model definition skipped
}, {
freezeTableName: true,
timestamps: false
});

... 如 the docs 中所述.

关于Node.js、sequelize 和 Unknown 专栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39374527/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com