Sequelize: Query an association table <p>I have trouble querying an association table using sequelize. I have 3 tables: User, Roles and UserRoles. A user can have many roles.</p> <p>I am trying to query in UserRoles (which stores userID and roleID ).</p> <pre><code>var User = sequelize.define('User', { // }, { classMethods: { associate: function(models) { User.belongsToMany(models.Role, { through: 'UserRole' }); var Role = sequelize.define('Role', { // }, { classMethods: { associate: function(models) { Role.belongsToMany(models.User, { through: 'UserRole' }); } } }); </code></pre> <p>I suspect the problem is with UserRole Model defition.</p> <pre><code>var UserRole = sequelize.define('UserRole', { // }, { associate: function(models) { UserRole.belongsTo(models.User, { foreignKey: 'UserId', foreignKeyConstraint: true, targetKey: 'id' }); UserRole.belongsTo(models.Role, { foreignKey: 'RoleId', foreignKeyConstraint: true, targetKey: 'id' }); } db.UserRole.findAll({ //Returns empty }) </code></pre>