Reputation: 3043
I'm new to Sequelize, I have the following schema (it's an example) :
How can I use sequelize to get All users that live in a given city,
I looked in Sequelize doc, but I don't figure out how to make indirect association filter.
Upvotes: 0
Views: 58
Reputation: 2301
You have to add an include of the model that has the association on each step.
const users = await db.User.findAll({
include: [{
model: db.Country,
as: 'Country',
include: [{
model: db.City,
as: 'Cities',
where: {} // here goes your condition
}]
}],
});
Upvotes: 1