Type Alias HasOneSetAssociationMixin<T, TModelPrimaryKey>

HasOneSetAssociationMixin: {
    (
        newAssociation: null,
        options?: HasOneSetAssociationMixinOptions<T>,
    ): Promise<null>;
    (
        newAssociation: T | TModelPrimaryKey,
        options?: HasOneSetAssociationMixinOptions<T>,
    ): Promise<T>;
}

The setAssociation mixin applied to models with hasOne. An example of usage is as follows:

class User extends Model<InferAttributes<User>, InferCreationAttributes<User>> {
declare setRole: HasOneSetAssociationMixin<Role, Role['id']>;
}

User.hasOne(Role);

Type Parameters

  • T extends Model
  • TModelPrimaryKey

Type declaration

Model.hasOne