Sequelize Where On Many-to-many Join
I am hoping somebody can help me. I am using the Sequelize ORM for express.js and I have a working many-to-many relationship between 2 tables. For the sake of simplifying my query
Solution 1:
With Belongs-To-Many you can query based on through relation and select specific attributes. For example using findAll with through
User.findAll({
include: [{
model: Project,
through: {
attributes: ['createdAt', 'startedAt', 'finishedAt']
where: {completed: true}
}
}]
});
Basically you can use through
option and include
the relationship that you linked. More can be found here
Post a Comment for "Sequelize Where On Many-to-many Join"