I'm sorry but I was unable to find a clear response to this question neither in the doc and the net ### How can I update a join table? Given this scenario: ```javascript UserProject = sequelize.define('user_project', { role: Sequelize.STRING }); User.belongsToMany(Project, { through: UserProject }); Project.belongsToMany(User, { through: UserProject }); const user = ... // some User instance const project = ... // some Project instance user.addProject(project, { through: { role: 'manager' }}); ``` #### What is the right way to update the previous role? I found re-adding the same project to the user: ```javascript user.addProject(project, { through: { role: 'product owner' }}); ``` works and updates the role but.. is this the right way?
Activity
sushantdhiman commentedon Mar 22, 2018
If N:M through model is having unique pair of foreign keys (default behaviour) then
addProjectis a good solutionOtherwise directly finding that record on
throughtable and updating it also an viable option