pub struct Repository<M = ()> { /* private fields */ }Expand description
Full CRUD access to one model over a store; usable as an axum extractor.
Implementations§
Source§impl<M: Model> Repository<M>
impl<M: Model> Repository<M>
Sourcepub async fn save(&self, model: &mut M) -> Result<(), StoreError>
pub async fn save(&self, model: &mut M) -> Result<(), StoreError>
Insert the model and store its generated key.
Sourcepub async fn save_many(&self, models: &mut [M]) -> Result<(), StoreError>
pub async fn save_many(&self, models: &mut [M]) -> Result<(), StoreError>
Insert a batch of models in one call.
Sourcepub async fn get(&self, id: &Value) -> Result<Option<M>, StoreError>
pub async fn get(&self, id: &Value) -> Result<Option<M>, StoreError>
Load one model by key value.
Sourcepub async fn all(&self) -> Result<Vec<M>, StoreError>
pub async fn all(&self) -> Result<Vec<M>, StoreError>
All models ordered by key.
Sourcepub async fn filter(
&self,
field: Name,
value: &Value,
) -> Result<Vec<M>, StoreError>
pub async fn filter( &self, field: Name, value: &Value, ) -> Result<Vec<M>, StoreError>
Models whose given field equals the value.
Sourcepub async fn ordered(&self, sort: Sort) -> Result<Vec<M>, StoreError>
pub async fn ordered(&self, sort: Sort) -> Result<Vec<M>, StoreError>
All models with the given sort applied.
Sourcepub async fn scan_query(&self, query: &Query) -> Result<Vec<M>, StoreError>
pub async fn scan_query(&self, query: &Query) -> Result<Vec<M>, StoreError>
Models matched by the query, refusing projected rows.
Sourcepub async fn rows(&self, query: &Query) -> Result<Vec<Row>, StoreError>
pub async fn rows(&self, query: &Query) -> Result<Vec<Row>, StoreError>
Raw rows matched by the query.
Sourcepub async fn total_query(&self, query: &Query) -> Result<usize, StoreError>
pub async fn total_query(&self, query: &Query) -> Result<usize, StoreError>
Count of rows matched by the query.
Sourcepub async fn mass(&self, query: &Query) -> Result<Value, StoreError>
pub async fn mass(&self, query: &Query) -> Result<Value, StoreError>
Aggregate value computed by the query’s mass action.
Trait Implementations§
Source§impl<M: Model> FromRequestParts<()> for Repository<M>
impl<M: Model> FromRequestParts<()> for Repository<M>
Auto Trait Implementations§
impl<M = ()> !RefUnwindSafe for Repository<M>
impl<M = ()> !UnwindSafe for Repository<M>
impl<M> Forget for Repository<M>
impl<M> Freeze for Repository<M>where
PhantomData<M>: Freeze,
impl<M> Send for Repository<M>where
PhantomData<M>: Send,
impl<M> Sync for Repository<M>where
PhantomData<M>: Sync,
impl<M> Unpin for Repository<M>where
PhantomData<M>: Unpin,
impl<M> UnsafeUnpin for Repository<M>where
PhantomData<M>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
Perform the extraction.
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more