Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface BelongsToManyOptions

Options provided when associating models with Model.belongsToMany relationship

Hierarchy

Index

Properties

as?: string | { plural: string; singular: string }

The alias of this model, in singular form. See also the name option passed to sequelize.define. If you create multiple associations between the same tables, you should provide an alias to be able to distinguish between them. If you provide an alias when creating the assocition, you should provide the same alias when eager loading and when getting associated models. Defaults to the singularized name of target

constraints?: boolean

Should on update and on delete constraints be enabled on the foreign key.

foreignKey?: string | ForeignKeyOptions

The name of the foreign key in the target table or an object representing the type definition for the foreign column (see Sequelize.define for syntax). When using an object, you can add a name property to set the name of the column. Defaults to the name of source + primary key of source

foreignKeyConstraint?: boolean
hooks?: boolean

If false the applicable hooks will not be called. The default value depends on the context.

default

true

onDelete?: string

What happens when delete occurs.

Cascade if this is a n:m, and set null if it is a 1:m

One of RESTRICT, CASCADE, NO ACTION, SET DEFAULT, or SET NULL

default

'SET NULL' or 'CASCADE'

onUpdate?: string

What happens when update occurs

One of RESTRICT, CASCADE, NO ACTION, SET DEFAULT, or SET NULL

default

'CASCADE'

otherKey?: string | ForeignKeyOptions

The name of the foreign key in the join table (representing the target model) or an object representing the type definition for the other column (see Sequelize.define for syntax). When using an object, you can add a name property to set the name of the colum. Defaults to the name of target + primary key of target

A key/value set that will be used for association create and find defaults on the target. (sqlite not supported for N:M)

sourceKey?: string

The name of the field to use as the key for the association in the source table. Defaults to the primary key of the source table

targetKey?: string

The name of the field to use as the key for the association in the target table. Defaults to the primary key of the target table

through: string | ModelStatic<Model<any, any>> | ThroughOptions

The name of the table that is used to join source and target in n:m associations. Can also be a sequelize model if you want to define the junction table yourself and add extra attributes to it.

timestamps?: boolean

Should the join model have timestamps

uniqueKey?: string

The unique key name to override the autogenerated one when primary key is not present on through model

Generated using TypeDoc