0
我在sequelize創建了以下型號:錯誤找不到
export function initialize(sequelize: Sequelize.Sequelize, dataTypes: Sequelize.DataTypes): SalesPerson.Model {
var salesPersonModel = sequelize.define<SalesPerson, SalesPerson.Pojo>('salesPerson', {
ownerId: { type: dataTypes.STRING, allowNull: false, field: 'owner_id' },
firstName: { type: dataTypes.STRING, allowNull: false, field: 'first_name' },
lastName: { type: dataTypes.STRING, allowNull: false, field: 'last_name' },
email: { type: dataTypes.STRING, allowNull: false }
}, {
underscored: true,
tableName: 'sales_persons'
});
salesPersonModel.removeAttribute('id');
return salesPersonModel;
}
開始sequelize.sync()
後正確地創建表。問題是,當我做出這樣的查詢:
db.SalesPerson.find({ limit: 1, order: [['updated_at DESC']] })...
我得到了以下錯誤:
Unhandled rejection SequelizeDatabaseError: ER_BAD_FIELD_ERROR: Unknown column 'salesPerson.updated_at DESC' in 'order clause'
,這並沒有意義,因爲我在數據庫中的列,因此應該是相關信息請參見與sequelize