Class Entity<EntityEvent>Abstract

Entities are not fundamentally defined by their properties, but rather by a thread of continuity and identity. An object defined primarily by its identity is called an Entity.

Type Parameters

Constructors

Properties

createdAt?: DateValue
updatedAt?: DateValue

Methods

  • Compares two Entities for equality. If both identifiers are Identity objects, then the comparison is made by the value of the identifiers. Otherwise, the comparison is made by the reference of the identifiers.

    Parameters

    Returns boolean

  • Validates any defined invariants depending on its implementation, and raises the event. The Domain Event is raised by adding it to the list of pending events of the Aggregate root in the event sink. It's recommended to call this method after mutating the state of the Aggregate.

    Parameters

    • aDomainEvent: EntityEvent
    • shouldUpdateDates: boolean = true

    Returns void

  • Validates any defined invariants depending on its implementation. It's an optional abstract method that, if defined, will be called before raising events.

    Returns void

  • Decorator that enforces invariants for decorated class methods in TypeScript by calling validateInvariants before raising events.

    Returns MethodDecorator