pub struct InMemoryRepository<E>{ /* private fields */ }Expand description
内存仓储实现
使用 Vec<E> 存储实体,主键通过 key_of 提取。
适合单元测试、原型开发、无数据库场景。
Implementations§
Source§impl<E> InMemoryRepository<E>
impl<E> InMemoryRepository<E>
Trait Implementations§
Source§impl<E> Default for InMemoryRepository<E>
impl<E> Default for InMemoryRepository<E>
Source§fn default() -> InMemoryRepository<E>
fn default() -> InMemoryRepository<E>
Returns the “default value” for a type. Read more
Source§impl<E> Repository<E> for InMemoryRepository<E>
InMemoryRepository 的 EntityAttributes-based 实现
impl<E> Repository<E> for InMemoryRepository<E>
InMemoryRepository 的 EntityAttributes-based 实现
Source§fn key_of(&self, entity: &E) -> <InMemoryRepository<E> as Repository<E>>::Key
fn key_of(&self, entity: &E) -> <InMemoryRepository<E> as Repository<E>>::Key
提取实体的主键
Source§fn find_by_id(
&self,
key: &<InMemoryRepository<E> as Repository<E>>::Key,
) -> Result<Option<E>, RepositoryError>
fn find_by_id( &self, key: &<InMemoryRepository<E> as Repository<E>>::Key, ) -> Result<Option<E>, RepositoryError>
按主键查找
Source§fn find_by(
&self,
conditions: &[WhereCondition],
) -> Result<Vec<E>, RepositoryError>
fn find_by( &self, conditions: &[WhereCondition], ) -> Result<Vec<E>, RepositoryError>
按条件查询
Source§fn delete(
&self,
key: &<InMemoryRepository<E> as Repository<E>>::Key,
) -> Result<usize, RepositoryError>
fn delete( &self, key: &<InMemoryRepository<E> as Repository<E>>::Key, ) -> Result<usize, RepositoryError>
按主键删除
Source§fn find_one_by(
&self,
conditions: &[WhereCondition],
) -> Result<Option<E>, RepositoryError>
fn find_one_by( &self, conditions: &[WhereCondition], ) -> Result<Option<E>, RepositoryError>
按条件查询单条
Source§fn batch_update(
&self,
entities: Vec<E>,
) -> Result<BatchUpdateResult<E>, RepositoryError>
fn batch_update( &self, entities: Vec<E>, ) -> Result<BatchUpdateResult<E>, RepositoryError>
批量更新(S-1:SeaORM 对标短板补全) Read more
Source§fn delete_by(
&self,
conditions: &[WhereCondition],
) -> Result<usize, RepositoryError>
fn delete_by( &self, conditions: &[WhereCondition], ) -> Result<usize, RepositoryError>
按条件删除
Source§fn count_by(
&self,
conditions: &[WhereCondition],
) -> Result<u64, RepositoryError>
fn count_by( &self, conditions: &[WhereCondition], ) -> Result<u64, RepositoryError>
按条件计数
Source§fn paginate(
&self,
page: u64,
page_size: u64,
) -> Result<PageResult<E>, RepositoryError>where
E: Clone,
fn paginate(
&self,
page: u64,
page_size: u64,
) -> Result<PageResult<E>, RepositoryError>where
E: Clone,
分页查询
Source§fn paginate_by(
&self,
conditions: &[WhereCondition],
page: u64,
page_size: u64,
) -> Result<PageResult<E>, RepositoryError>where
E: Clone,
fn paginate_by(
&self,
conditions: &[WhereCondition],
page: u64,
page_size: u64,
) -> Result<PageResult<E>, RepositoryError>where
E: Clone,
按条件分页查询
Source§fn find_by_with_or_filter(
&self,
and: &[WhereCondition],
or_filter: &[WhereCondition],
) -> Result<Vec<E>, RepositoryError>where
E: Clone + EntityAttributes,
fn find_by_with_or_filter(
&self,
and: &[WhereCondition],
or_filter: &[WhereCondition],
) -> Result<Vec<E>, RepositoryError>where
E: Clone + EntityAttributes,
按 AND 条件查询,并对结果应用额外的 OR 过滤组 Read more
Auto Trait Implementations§
impl<E> !Freeze for InMemoryRepository<E>
impl<E> RefUnwindSafe for InMemoryRepository<E>
impl<E> Send for InMemoryRepository<E>
impl<E> Sync for InMemoryRepository<E>
impl<E> Unpin for InMemoryRepository<E>where
E: Unpin,
impl<E> UnsafeUnpin for InMemoryRepository<E>
impl<E> UnwindSafe for InMemoryRepository<E>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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