Skip to content

postgrelize / AssociationOptions

Type Alias: AssociationOptions ​

AssociationOptions = Readonly<{ as?: string | AssociationName; constraints?: boolean; foreignKey?: string | ForeignKeyOptions; hooks?: boolean; onDelete?: string; onUpdate?: string; scope?: Readonly<Record<string, unknown>>; sourceKey?: string; targetKey?: string; }>

Defined in: src/associations/types.ts:49

Options shared by all association methods (Sequelize v6 AssociationOptions).

Used by hasOne, hasMany, belongsTo and (extended) belongsToMany.

See ​

Model.hasMany

Example ​

ts
const opts: AssociationOptions = {
  as: 'posts',
  foreignKey: { name: 'authorId', allowNull: false },
  onDelete: 'CASCADE',
};
User.hasMany(Post, opts);

Released under the MIT License.