0
I have in my database a table called Chefs
, and another table Recipes
receiving a foreign key called chef_id
.
Using Sequelize I built in my Controller a code that returns the data of chefs
together with the revenues linked to it.
async homeChefsList(req, res) {
try {
const chefs = await Chef.findAll({
include: {
association: 'recipes'
},
})
return res.json(chefs)
} catch (error) {
console.error(error);
}
}
Now I want him to do a count of the recipes that are tied to that chef. I tried to use the example that has on sequelize documentation, but it didn’t work out.
Project link on Github: https://github.com/SamuelB7/foodfy