Specification Repository Port¶
specification_repository_port
¶
Specification-aware repository port.
Extends ReadOnlyRepository with query methods that accept
Specification predicates for in-memory filtering.
SpecificationRepositoryPort
¶
Bases: ReadOnlyRepositoryPort[TEntity, TId]
Read-only repository port with Specification-based query support.
In addition to standard read-only operations, this interface
allows querying by Specification predicates.
Responsibilities
- Find all entities matching a
Specificationpredicate. - Count entities satisfying a specification.
- Check whether any entity matches a specification.
Non-Responsibilities
- Compile or optimize
Specificationpredicates. - Paginate or sort specification results.
- Provide indexing strategies — that belongs to infrastructure.
Example
Source code in src/forging_blocks/application/ports/outbound/specification_repository_port.py
find_matching(spec: Specification[TEntity]) -> Sequence[TEntity]
abstractmethod
async
¶
Return all entities that satisfy the specification.
count_matching(spec: Specification[TEntity]) -> int
abstractmethod
async
¶
Return the count of entities satisfying the specification.
exists_matching(spec: Specification[TEntity]) -> bool
abstractmethod
async
¶
Return True if at least one entity satisfies the specification.