pub trait ReadRepository<T: AggregateRoot>: Send + Sync {
    fn get_by_id<'life0, 'async_trait>(
        &'life0 self,
        id: <T as Entity>::Id
    ) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn list<'life0, 'async_trait>(
        &'life0 self,
        skip: usize,
        take: usize
    ) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn count<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn any<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
, { ... } }
Expand description

Trait for representing a read-only Repository.

Required Methods§

source

fn get_by_id<'life0, 'async_trait>(
    &'life0 self,
    id: <T as Entity>::Id
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,

Gets an entity with the given ID.

source

fn list<'life0, 'async_trait>(
    &'life0 self,
    skip: usize,
    take: usize
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,

Lists all entities within a given page.

source

fn count<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,

Returns the total number of entities in the repository.

Provided Methods§

source

fn any<'life0, 'async_trait>(
    &'life0 self
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,

Returns a boolean whether the repository is not empty.

Implementors§

source§

impl<T: AggregateRoot + Clone> ReadRepository<T> for InMemoryRepository<T>where
    <T as Entity>::Id: Hash + Eq,

source§

impl<T: AggregateRoot, TRepository: Repository<T>, TDomainEventHandler: DomainEventHandler<<T as AggregateRoot>::DomainEvent>> ReadRepository<T> for DomainRepository<T, TRepository, TDomainEventHandler>