{"action":"opened","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/9204","repository_url":"https://api.github.com/repos/sequelize/sequelize","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/9204/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/9204/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/9204/events","html_url":"https://github.com/sequelize/sequelize/issues/9204","id":306773921,"number":9204,"title":"Update join table","user":{"login":"acanimal","id":732033,"avatar_url":"https://avatars0.githubusercontent.com/u/732033?v=4","gravatar_id":"","url":"https://api.github.com/users/acanimal","html_url":"https://github.com/acanimal","followers_url":"https://api.github.com/users/acanimal/followers","following_url":"https://api.github.com/users/acanimal/following{/other_user}","gists_url":"https://api.github.com/users/acanimal/gists{/gist_id}","starred_url":"https://api.github.com/users/acanimal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acanimal/subscriptions","organizations_url":"https://api.github.com/users/acanimal/orgs","repos_url":"https://api.github.com/users/acanimal/repos","events_url":"https://api.github.com/users/acanimal/events{/privacy}","received_events_url":"https://api.github.com/users/acanimal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-20T08:47:10Z","updated_at":"2018-03-20T08:47:10Z","closed_at":null,"author_association":"NONE","body":"I'm sorry but I was unable to find a clear response to this question neither in the doc and the net\r\n\r\n### How can I update a join table?\r\n\r\nGiven this scenario:\r\n\r\n```javascript\r\nUserProject = sequelize.define('user_project', {\r\n  role: Sequelize.STRING\r\n});\r\nUser.belongsToMany(Project, { through: UserProject });\r\nProject.belongsToMany(User, { through: UserProject });\r\n\r\nconst user = ...  // some User instance\r\nconst project = ...  // some Project instance\r\n\r\nuser.addProject(project, { through: { role: 'manager' }});\r\n```\r\n#### What is the right way to update the previous role?\r\n\r\nI found re-adding the same project to the user:\r\n\r\n```javascript\r\nuser.addProject(project, { through: { role: 'product owner' }});\r\n```\r\n\r\n works and updates the role but.. is this the right way?"}}
{"actor":{"display_login":"acanimal"}}