Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Indroic/HexCore/llms.txt
Use this file to discover all available pages before exploring further.
BaseEntity is the foundation every entity in your domain inherits from. It ships with a UUID primary key, UTC timestamps, a soft-delete flag, and a private event queue that lets the entity record domain events for later dispatch. Configuration is handled through Pydantic’s model_config, giving you ORM compatibility (from_attributes=True) and field-level re-validation (validate_assignment=True) out of the box.
Also included in hexcore.domain.base is AbstractModelMeta, a thin compatibility shim that resolves the metaclass conflict between Pydantic and Python’s abc.ABCMeta.
Class definition
Fields
Unique universal identifier for the entity. Auto-generated with
uuid4() when not provided.UTC timestamp set at creation time via
datetime.now(UTC). Never updated after the entity is first saved.UTC timestamp updated every time the entity is modified. Defaults to
datetime.now(UTC) on instantiation.Soft-delete flag. Set to
False by calling deactivate() instead of issuing a hard DELETE against the data store.Methods
register_event
DomainEvent to the entity’s internal event queue. Call this inside domain methods whenever a significant state change has occurred. The event is held in memory until either pull_domain_events() or clear_domain_events() is called.
The domain event instance to enqueue.
pull_domain_events
All domain events that were registered since the last call to
pull_domain_events() or clear_domain_events().clear_domain_events
deactivate
is_active = False, implementing logical (soft) deletion. The entity record is preserved in the data store; it simply stops appearing in active queries. Because validate_assignment=True is set, Pydantic re-validates the field on assignment.
AbstractModelMeta
AbstractModelMeta is a convenience base class that combines BaseEntity and abc.ABC in a single type. Its sole purpose is to resolve the metaclass conflict that arises when a class tries to inherit from both a Pydantic BaseModel (which uses ModelMetaclass) and an abstract base class (which uses ABCMeta).
You should inherit from
AbstractModelMeta whenever you need to mark methods as @abstractmethod on a class that also inherits BaseEntity. Never try to set metaclass=... manually on a Pydantic model.