Sequelize many to many with extra columns

node.js, sequelize.js

Solution

If you are using Sequelize version 4.x there is some changes in the API

Relationships add/set/create setters now set through attributes by passing them as options.through (previously second argument was used as through attributes, now its considered options with through being a sub option)

user.addNotification(notification, { through: {cityId: 1, active: true}});

Problem

After some research I didn't find anything related to my problem. So the setting is an M:M relationship already working with sequelize (sqllite): ``` return User.find({ where: { _id: userId } }).then(user => { logger.info(`UserController - found user`); Notification.find({ where: { _id: notificationId } }).then(notification => { if (associate) { return user.addNotification([notification]); } else { return user.removeNotification([notification]); } }) }) ``` The thing is that I have extra fields in the inter table(cityId, active) and I don't know how to update it when running "addNotification". Thanks in advance

Original source