The model on which Model.belongsTo has been called, on which the association methods, as well as the foreign key attribute, will be added.
The model passed to Model.belongsTo.
The name of the Foreign Key attribute on the Source model.
The name of the attribute that the foreign key in the source model will reference, typically the Primary Key.
Optionalparent: Association<ReadonlyaccessorsThe column name of the foreign key
ReadonlyoptionsReadonlyparentA reference to the association that created this one.
The name of the attribute the foreign key points to. In belongsTo, this key is on the Target Model, instead of the Source Model (unlike HasOneAssociation.sourceKey). The Association.foreignKey is on the Source Model.
ReadonlytargetThe column name of the target key
ReadonlytargetThe identifier of the relation on the source model.
The type of the association. One of HasMany, BelongsTo, HasOne, BelongsToMany
negate isMultiAssociation instead
Creating an associations can automatically create other associations. This returns the initial association that caused the creation of the descendant associations.
StaticisCreate a new instance of the associated model and associate it with this.
the source instance
values to create associated model instance with
Options passed to target.create and setAssociation.
The created target model
Get the associated instance.
See BelongsToGetAssociationMixinOptions for a full explanation of options. This method is mixed-in the source model prototype. See BelongsToGetAssociationMixin.
source instances
Optionaloptions: BelongsToGetAssociationMixinOptions<T>find options
Get the associated instance.
See BelongsToGetAssociationMixinOptions for a full explanation of options. This method is mixed-in the source model prototype. See BelongsToGetAssociationMixin.
source instances
Optionaloptions: BelongsToGetAssociationMixinOptions<T>find options
ProtectedinferStaticassociateOptionalparent: Association<any, Model<any, any>, string, NormalizedAssociationOptions<string>>
One-to-one association See Model.belongsTo
This is almost the same as HasOneAssociation, but the foreign key will be defined on the source model.
In the API reference below, add the name of the association to the method, e.g. for
User.belongsTo(Project)the getter will beuser.getProject().