I was going through document of sequelize. In my database I had user and roles having n:m relations. http://docs.sequelizejs.com/manual/tutorial/associations.html#belongs-to-many-associations
User.hasMany(Teams, {through: UserTeams});
Teams.hasMany(User, {through: UserTeams});
This creates another table UserTeams. Now UserTeams has m:n relation with Styles. Therefore the relations will be defined as:
UserTeams.hasMany({Styles, {through: UserTeamStyles});
Styles.hasMany({UserTeams, {through: UserTeamStyles});
User.findAll({
include: [{
model: Teams,
through: {
attributes: ['a','b','c']
}
}]
});
This will give me data=> User left join with UserTeams and inner join with Teams. How can I get the data of UserTeamStyles and styles along with this data in a single query?