Skip to content

Specification Repository Port

specification_repository_port

Specification-aware repository protocol.

Extends ReadOnlyRepository with query methods that accept
Specification predicates for in-memory filtering.

SpecificationRepositoryPort

Bases: ReadOnlyRepositoryPort[TEntity, TId], Protocol

RepositoryPort that supports specification-based queries.

In addition to standard read-only operations, this interface
allows querying by Specification predicates.

Source code in src/forging_blocks/application/ports/outbound/specification_repository_port.py
class SpecificationRepositoryPort[TEntity, TId](ReadOnlyRepositoryPort[TEntity, TId], Protocol):
    """RepositoryPort that supports specification-based queries.

    In addition to standard read-only operations, this interface
    allows querying by ``Specification`` predicates.
    """

    async def find_matching(self, spec: Specification[TEntity]) -> Sequence[TEntity]:
        """Return all entities that satisfy the specification."""
        ...

    async def count_matching(self, spec: Specification[TEntity]) -> int:
        """Return the count of entities satisfying the specification."""
        ...

    async def exists_matching(self, spec: Specification[TEntity]) -> bool:
        """Return ``True`` if at least one entity satisfies the specification."""
        ...

find_matching(spec: Specification[TEntity]) -> Sequence[TEntity] async

Return all entities that satisfy the specification.

Source code in src/forging_blocks/application/ports/outbound/specification_repository_port.py
async def find_matching(self, spec: Specification[TEntity]) -> Sequence[TEntity]:
    """Return all entities that satisfy the specification."""
    ...

count_matching(spec: Specification[TEntity]) -> int async

Return the count of entities satisfying the specification.

Source code in src/forging_blocks/application/ports/outbound/specification_repository_port.py
async def count_matching(self, spec: Specification[TEntity]) -> int:
    """Return the count of entities satisfying the specification."""
    ...

exists_matching(spec: Specification[TEntity]) -> bool async

Return True if at least one entity satisfies the specification.

Source code in src/forging_blocks/application/ports/outbound/specification_repository_port.py
async def exists_matching(self, spec: Specification[TEntity]) -> bool:
    """Return ``True`` if at least one entity satisfies the specification."""
    ...