I am trying to filter my query by the attributes of the joining table
I have 2 tables Cities and Categories which I am associating through a third table CityCategory
When querying the through table, you should use through.where
include: [{
model: Category,
through: { where: {year: 2015}},
attributes: ['id']
}]
You might want to add required: true
to turn the include to an inner join
For Sequelize v3 it appears the syntax is closer to what you suggested, that is:
include: [{
model: Category,
where: {year: 2015},
attributes: ['id']
}]