Interface EntityAssociationDefinition<TViewerContext, TAssociatedFields, TAssociatedID, TAssociatedEntity, TAssociatedPrivacyPolicy, TAssociatedSelectedFields>

Defines an association between entities. An association is primarily used to define cascading deletion behavior.

Type Parameters

  • TViewerContext extends ViewerContext

  • TAssociatedFields extends object

  • TAssociatedID extends NonNullable<TAssociatedFields[TAssociatedSelectedFields]>

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

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

  • TAssociatedSelectedFields extends keyof TAssociatedFields = keyof TAssociatedFields

Hierarchy

  • EntityAssociationDefinition

Properties

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

Class of entity on the other end of this edge.

associatedEntityLookupByField?: keyof TAssociatedFields

Field by which to load the instance of associatedEntityClass. If not provided, the associatedEntityClass instance is fetched by its ID.

edgeDeletionBehavior: EntityEdgeDeletionBehavior

What action to perform on the current entity when the entity on the referencing end of this edge is deleted.

Remarks

The entity framework doesn't prescribe a one-size-fits-all solution for referential integrity; instead it exposes mechanisms that support both database foreign key constraints and implicit entity-specified foreign keys. Choosing which approach to use often depends on application requirements, and sometimes even a mix-and-match is the right choice.

  • If referential integrity is critical to your application, database foreign key constraints combined with EntityEdgeDeletionBehavior.CASCADE_DELETE_INVALIDATE_CACHE_ONLY or EntityEdgeDeletionBehavior.SET_NULL_INVALIDATE_CACHE_ONLY are recommended.
  • If the database being used doesn't support foreign keys, then using the entity framework for referential integrity is recommended.

Generated using TypeDoc