Estou recebendo o erro:
EagerLoadingError [SequelizeEagerLoadingError]: Setor is not associated to Produto!
Estou usando o Sequelize.
Meu model Setor esta assim:
'use strict'
module.exports = (sequelize, DataTypes) => {
const Setores = sequelize.define('Setor', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
field: 'id'
},
descricao: {
type: DataTypes.STRING,
field:'descricao'
},
}, {
freezeTableName: true,
schema: 'public',
tableName: 'setor',
timestamps: false
})
return Setores
}
E meu model produto esta assim:
'use strict'
module.exports = (sequelize, DataTypes) => {
const Produtos = sequelize.define('Produto', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true,
field: 'id'
},
descricao: {
type: DataTypes.STRING,
field: 'descricao'
},
barra: {
type: DataTypes.STRING,
field: 'barra'
},
id_setor: {
type: DataTypes.INTEGER,
field: 'id_setor',
references: {
model: Setor,
key: 'id'
}
}
}, {
freezeTableName: true,
schema: 'public',
tableName: 'produto',
timestamps: false,
classMethods: {
associate: (model) => {
Produtos.belongsTo(model.Setor, { foreignKey: 'id_setor' })
}
}
})
return Produtos
}
Coloquei igual o post que estou lendo. O que pode estar errado?