postgrelize / Association
Abstract Class: Association<S, T> ​
Defined in: src/associations/association.ts:39
Association between two models (Sequelize v6 Association). Subclasses resolve the keys, add the foreign key attributes and implement the accessor methods that are installed on the source prototype (getX, setX, createX, ...).
Example ​
const association: Association<Post, User> = Post.belongsTo(User);
association.associationType; // 'BelongsTo'Type Parameters ​
S ​
Instance type of the source model.
T ​
Instance type of the target model.
Implements ​
Association
Constructors ​
Constructor ​
protectednew Association<S,T>(type,source,target,options,name,keys):Association<S,T>
Defined in: src/associations/association.ts:88
Creates the association description; subclasses call install() afterwards.
Parameters ​
type ​
Kind of association.
source ​
ModelStatic<S>
Model the association is defined on.
target ​
ModelStatic<T>
Associated model.
options ​
Association options.
name ​
Singular and plural alias forms.
keys ​
AssociationKeyFields
Resolved keys.
Returns ​
Association<S, T>
Properties ​
accessors ​
readonlyaccessors:Readonly<Record<string,string>>
Defined in: src/associations/association.ts:62
Names of the instance methods added to the source model.
Implementation of ​
AssociationFields.accessors
as ​
readonlyas:string
Defined in: src/associations/association.ts:50
Alias used in include and as the instance property.
Implementation of ​
AssociationFields.as
associationType ​
readonlyassociationType:AssociationType
Defined in: src/associations/association.ts:44
Kind of association.
Implementation of ​
AssociationFields.associationType
foreignKey ​
readonlyforeignKey:string
Defined in: src/associations/association.ts:66
Foreign key attribute (on the source for belongsTo, on the target for hasOne/hasMany, on the junction for belongsToMany).
Implementation of ​
AssociationFields.foreignKey
identifierField ​
readonlyidentifierField:string
Defined in: src/associations/association.ts:68
Column of the foreign key.
Implementation of ​
AssociationFields.identifierField
isAliased ​
readonlyisAliased:boolean
Defined in: src/associations/association.ts:54
Whether as was given explicitly.
Implementation of ​
AssociationFields.isAliased
isMultiAssociation ​
readonlyisMultiAssociation:boolean
Defined in: src/associations/association.ts:60
True for hasMany / belongsToMany.
Implementation of ​
AssociationFields.isMultiAssociation
isSingleAssociation ​
readonlyisSingleAssociation:boolean
Defined in: src/associations/association.ts:58
True for belongsTo / hasOne.
Implementation of ​
AssociationFields.isSingleAssociation
name ​
readonlyname:AssociationName
Defined in: src/associations/association.ts:52
Singular and plural alias forms.
Implementation of ​
AssociationFields.name
options ​
readonlyoptions:AssociationOptions
Defined in: src/associations/association.ts:64
Options the association was defined with.
Implementation of ​
AssociationFields.options
otherKey ​
readonlyotherKey:string|undefined
Defined in: src/associations/association.ts:74
Junction foreign key pointing at the target (belongsToMany).
Implementation of ​
AssociationFields.otherKey
scope ​
readonlyscope:Readonly<Record<string,unknown>> |undefined
Defined in: src/associations/association.ts:56
Association scope.
Implementation of ​
AssociationFields.scope
source ​
readonlysource:ModelStatic<S>
Defined in: src/associations/association.ts:46
Model the association is defined on.
Implementation of ​
AssociationFields.source
sourceKey ​
readonlysourceKey:string
Defined in: src/associations/association.ts:70
Source attribute referenced by the foreign key.
Implementation of ​
AssociationFields.sourceKey
target ​
readonlytarget:ModelStatic<T>
Defined in: src/associations/association.ts:48
Associated model.
Implementation of ​
AssociationFields.target
targetKey ​
readonlytargetKey:string
Defined in: src/associations/association.ts:72
Target attribute referenced by the foreign key (belongsTo) or by otherKey (belongsToMany).
Implementation of ​
AssociationFields.targetKey
through ​
readonlythrough:Readonly<{model:ModelStatic<AnyModel>;scope?:Readonly<Record<string,unknown>>; }> |undefined
Defined in: src/associations/association.ts:76
Junction model (belongsToMany).
Implementation of ​
AssociationFields.through