当我尝试通过Sequelize从NODEJS中的某个路由获取数据时,出现未知列错误,该错误既不在模型中,也不在下面,路由是我的代码。
我的模特
module.exports = function(sequelize, DataTypes) {
return sequelize.define('ProspectType', {
ProspectTypeID: {
type: DataTypes.INTEGER(11),
allowNull: false
},
ProspectTypeName: {
type: DataTypes.STRING(50),
allowNull: true
}
}, {
tableName: 'ProspectType'
});
};
Run Code Online (Sandbox Code Playgroud)
我的路线
.get('/prospectType', function (req, res) {
models
.ProspectType
.findAll()
.then(function (data) {
res
.json(data);
})
.catch(function (error) {
res
.boom
.notAcceptable(error);
});
})
Run Code Online (Sandbox Code Playgroud)
即使没有列“ id”,我也会收到此错误
SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column 'id' in 'field
list'
Run Code Online (Sandbox Code Playgroud)