Class EntityAssociationLoader<TFields, TID, TViewerContext, TEntity, TSelectedFields>

An association loader is a set of convenience methods for loading entities associated with an entity. In relational databases, these entities are often referenced by foreign keys.

Type Parameters

  • TFields extends object

  • TID extends NonNullable<TFields[TSelectedFields]>

  • TViewerContext extends ViewerContext

  • TEntity extends ReadonlyEntity<TFields, TID, TViewerContext, TSelectedFields>

  • TSelectedFields extends keyof TFields

Hierarchy

  • EntityAssociationLoader

Constructors

Properties

entity: TEntity

Methods

  • Load an associated entity identified by a field value of this entity. In a relational database, the field in this entity is a foreign key to the ID of the associated entity.

    Type Parameters

    • TIdentifyingField extends string | number | symbol

    • TAssociatedFields extends object

    • TAssociatedID extends {}

    • TAssociatedEntity extends ReadonlyEntity<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedSelectedFields, TAssociatedEntity>

    • TAssociatedPrivacyPolicy extends EntityPrivacyPolicy<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedSelectedFields, TAssociatedPrivacyPolicy>

    • TAssociatedSelectedFields extends string | number | symbol = keyof TAssociatedFields

    Parameters

    • fieldIdentifyingAssociatedEntity: TIdentifyingField

      field of this entity containing the ID of the associated entity

    • associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>

      class of the associated entity

    • queryContext: EntityQueryContext = ...

      query context in which to perform the load

    Returns Promise<Result<null extends TFields[TIdentifyingField]
        ? TAssociatedEntity | null
        : TAssociatedEntity>>

  • Load an associated entity identified by a field value of this entity. In a relational database, the field in this entity is a foreign key to a unique field of the associated entity.

    Type Parameters

    • TAssociatedFields extends object

    • TAssociatedID extends {}

    • TAssociatedEntity extends ReadonlyEntity<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedSelectedFields, TAssociatedEntity>

    • TAssociatedPrivacyPolicy extends EntityPrivacyPolicy<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedSelectedFields, TAssociatedPrivacyPolicy>

    • TAssociatedSelectedFields extends string | number | symbol = keyof TAssociatedFields

    Parameters

    • fieldIdentifyingAssociatedEntity: TSelectedFields

      field of this entity containing the value with which to look up associated entity

    • associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>

      class of the associated entity

    • associatedEntityLookupByField: TAssociatedSelectedFields

      field of associated entity with which to look up the associated entity

    • queryContext: EntityQueryContext = ...

      query context in which to perform the load

    Returns Promise<null | Result<TAssociatedEntity>>

  • Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each fold step, load an associated entity identified by a field value of the current fold value.

    Type Parameters

    • TFields2 extends object

    • TID2 extends {}

    • TEntity2 extends ReadonlyEntity<TFields2, TID2, TViewerContext, TSelectedFields2, TEntity2>

    • TPrivacyPolicy2 extends EntityPrivacyPolicy<TFields2, TID2, TViewerContext, TEntity2, TSelectedFields2, TPrivacyPolicy2>

    • TSelectedFields2 extends string | number | symbol = keyof TFields2

    Parameters

    • loadDirectives: [EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>]

      associated entity load directives instructing each step of the fold

    • Optional queryContext: EntityQueryContext

      query context in which to perform the loads

    Returns Promise<null | Result<TEntity2>>

  • Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each fold step, load an associated entity identified by a field value of the current fold value.

    Type Parameters

    • TFields2 extends object

    • TID2 extends {}

    • TEntity2 extends ReadonlyEntity<TFields2, TID2, TViewerContext, TSelectedFields2, TEntity2>

    • TPrivacyPolicy2 extends EntityPrivacyPolicy<TFields2, TID2, TViewerContext, TEntity2, TSelectedFields2, TPrivacyPolicy2>

    • TFields3 extends object

    • TID3 extends {}

    • TEntity3 extends ReadonlyEntity<TFields3, TID3, TViewerContext, TSelectedFields3, TEntity3>

    • TPrivacyPolicy3 extends EntityPrivacyPolicy<TFields3, TID3, TViewerContext, TEntity3, TSelectedFields3, TPrivacyPolicy3>

    • TSelectedFields2 extends string | number | symbol = keyof TFields2

    • TSelectedFields3 extends string | number | symbol = keyof TFields3

    Parameters

    • loadDirectives: [EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>, EntityLoadThroughDirective<TViewerContext, TFields2, TFields3, TID3, TEntity3, TPrivacyPolicy3, TSelectedFields2, TSelectedFields3>]

      associated entity load directives instructing each step of the fold

    • Optional queryContext: EntityQueryContext

      query context in which to perform the loads

    Returns Promise<null | Result<TEntity3>>

  • Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each fold step, load an associated entity identified by a field value of the current fold value.

    Type Parameters

    • TFields2 extends object

    • TID2 extends {}

    • TEntity2 extends ReadonlyEntity<TFields2, TID2, TViewerContext, TSelectedFields2, TEntity2>

    • TPrivacyPolicy2 extends EntityPrivacyPolicy<TFields2, TID2, TViewerContext, TEntity2, TSelectedFields2, TPrivacyPolicy2>

    • TFields3 extends object

    • TID3 extends {}

    • TEntity3 extends ReadonlyEntity<TFields3, TID3, TViewerContext, TSelectedFields3, TEntity3>

    • TPrivacyPolicy3 extends EntityPrivacyPolicy<TFields3, TID3, TViewerContext, TEntity3, TSelectedFields3, TPrivacyPolicy3>

    • TFields4 extends object

    • TID4 extends {}

    • TEntity4 extends ReadonlyEntity<TFields4, TID4, TViewerContext, TSelectedFields4, TEntity4>

    • TPrivacyPolicy4 extends EntityPrivacyPolicy<TFields4, TID4, TViewerContext, TEntity4, TSelectedFields4, TPrivacyPolicy4>

    • TSelectedFields2 extends string | number | symbol = keyof TFields2

    • TSelectedFields3 extends string | number | symbol = keyof TFields3

    • TSelectedFields4 extends string | number | symbol = keyof TFields4

    Parameters

    • loadDirective: [EntityLoadThroughDirective<TViewerContext, TFields, TFields2, TID2, TEntity2, TPrivacyPolicy2, TSelectedFields, TSelectedFields2>, EntityLoadThroughDirective<TViewerContext, TFields2, TFields3, TID3, TEntity3, TPrivacyPolicy3, TSelectedFields2, TSelectedFields3>, EntityLoadThroughDirective<TViewerContext, TFields3, TFields4, TID4, TEntity4, TPrivacyPolicy4, TSelectedFields3, TSelectedFields4>]
    • Optional queryContext: EntityQueryContext

      query context in which to perform the loads

    Returns Promise<null | Result<TEntity4>>

  • Load an associated entity by folding a sequence of EntityLoadThroughDirective. At each fold step, load an associated entity identified by a field value of the current fold value.

    Parameters

    • loadDirectives: EntityLoadThroughDirective<TViewerContext, any, any, any, any, any, any, any>[]

      associated entity load directives instructing each step of the fold

    • Optional queryContext: EntityQueryContext

      query context in which to perform the loads

    Returns Promise<null | Result<ReadonlyEntity<any, any, any, any>>>

  • Load many entities associated with this entity, often referred to as entites belonging to this entity. In a relational database, the field in the foreign entity is a foreign key to the ID of this entity. Also commonly referred to as a has many relationship, where this entity has many associated entities.

    Type Parameters

    • TAssociatedFields extends object

    • TAssociatedID extends {}

    • TAssociatedEntity extends ReadonlyEntity<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedSelectedFields, TAssociatedEntity>

    • TAssociatedPrivacyPolicy extends EntityPrivacyPolicy<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedSelectedFields, TAssociatedPrivacyPolicy>

    • TAssociatedSelectedFields extends string | number | symbol = keyof TAssociatedFields

    Parameters

    • associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>

      class of the associated entities

    • associatedEntityFieldContainingThisID: TAssociatedSelectedFields

      field of associated entity which contains the ID of this entity

    • queryContext: EntityQueryContext = ...

      query context in which to perform the load

    Returns Promise<readonly Result<TAssociatedEntity>[]>

  • Load many associated entities identified by a field value of this entity. In a relational database, the field in this entity refers to a field of the associated entity.

    Type Parameters

    • TAssociatedFields extends object

    • TAssociatedID extends {}

    • TAssociatedEntity extends ReadonlyEntity<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedSelectedFields, TAssociatedEntity>

    • TAssociatedPrivacyPolicy extends EntityPrivacyPolicy<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedSelectedFields, TAssociatedPrivacyPolicy>

    • TAssociatedSelectedFields extends string | number | symbol = keyof TAssociatedFields

    Parameters

    • fieldIdentifyingAssociatedEntity: TSelectedFields

      field of this entity containing the value with which to look up associated entities

    • associatedEntityClass: IEntityClass<TAssociatedFields, TAssociatedID, TViewerContext, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>

      class of the associated entities

    • associatedEntityLookupByField: TAssociatedSelectedFields

      field of associated entities with which to look up the associated entities

    • queryContext: EntityQueryContext = ...

      query context in which to perform the load

    Returns Promise<readonly Result<TAssociatedEntity>[]>

Generated using TypeDoc