pub trait Queryable<T: Entity>: Send + Sync {
type Filter: Send + Sync;
// Required methods
fn find_by(
&self,
filter: Self::Filter,
) -> BoxFuture<'_, Result<Vec<T>, RepoError>>;
fn find_page_by(
&self,
filter: Self::Filter,
request: PageRequest,
) -> BoxFuture<'_, Result<Page<T>, RepoError>>;
}Expand description
Trait for repositories that support filtered and sorted queries.
The Filter associated type allows each implementation to define
its own query DSL or filter struct without leaking persistence
details into the domain layer.
Note: Queryable is not object-safe because it has an associated type
(Filter). Use a concrete type or a trait alias when dynamic dispatch is needed.
Required Associated Types§
Required Methods§
Sourcefn find_by(
&self,
filter: Self::Filter,
) -> BoxFuture<'_, Result<Vec<T>, RepoError>>
fn find_by( &self, filter: Self::Filter, ) -> BoxFuture<'_, Result<Vec<T>, RepoError>>
Find all entities matching the given filter.
Sourcefn find_page_by(
&self,
filter: Self::Filter,
request: PageRequest,
) -> BoxFuture<'_, Result<Page<T>, RepoError>>
fn find_page_by( &self, filter: Self::Filter, request: PageRequest, ) -> BoxFuture<'_, Result<Page<T>, RepoError>>
Return a page of entities matching the given filter.
The total count and page items both reflect only rows that satisfy
filter. Use Paginatable::find_page when paginating the full table
without a filter.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".