Set the associated models by passing an array of instances or their primary keys. Everything that it not in the passed array will be un-associated.
User.belongsToMany(Role, { through: UserRole });
interface UserInstance extends Sequelize.Instance<UserInstance, UserAttributes>, UserAttributes {
// getRoles...
setRoles: Sequelize.BelongsToManySetAssociationsMixin<RoleInstance, RoleId, UserRoleAttributes>;
// addRoles...
// addRole...
// createRole...
// removeRole...
// removeRoles...
// hasRole...
// hasRoles...
// countRoles...
}
An array of instances or primary key of instances to associate with this. Pass null or undefined to remove all associations.
The options passed to through.findAll
, bulkCreate
, update
and destroy
. Can also hold additional attributes for the join table.
Generated using TypeDoc
The setAssociations mixin applied to models with belongsToMany. An example of usage is as follows:
User.belongsToMany(Role, { through: UserRole }); interface UserInstance extends Sequelize.Instance<UserInstance, UserAttributes>, UserAttributes { // getRoles... setRoles: Sequelize.BelongsToManySetAssociationsMixin<RoleInstance, RoleId, UserRoleAttributes>; // addRoles... // addRole... // createRole... // removeRole... // removeRoles... // hasRole... // hasRoles... // countRoles... }
http://docs.sequelizejs.com/en/latest/api/associations/belongs-to-many/
Instance