pub struct DbRepository<E: Entity + FromRow> { /* private fields */ }Expand description
基于数据库连接的仓储实现
Implementations§
Source§impl<E: Entity + FromRow> DbRepository<E>
impl<E: Entity + FromRow> DbRepository<E>
Sourcepub fn new(conn: Box<dyn DatabaseConnection>) -> Self
pub fn new(conn: Box<dyn DatabaseConnection>) -> Self
创建仓储
Sourcepub fn select(&self) -> SelectBuilder<E>
pub fn select(&self) -> SelectBuilder<E>
获取 SELECT 构建器
Sourcepub fn insert_builder(&self) -> InsertBuilder<E>
pub fn insert_builder(&self) -> InsertBuilder<E>
获取 INSERT 构建器
Sourcepub fn update_builder(&self) -> UpdateBuilder<E>
pub fn update_builder(&self) -> UpdateBuilder<E>
获取 UPDATE 构建器
Sourcepub fn delete_builder(&self) -> DeleteBuilder<E>
pub fn delete_builder(&self) -> DeleteBuilder<E>
获取 DELETE 构建器
Trait Implementations§
Source§impl<E: Entity + FromRow> Repository<E> for DbRepository<E>
Available on crate feature turso only.
impl<E: Entity + FromRow> Repository<E> for DbRepository<E>
Available on crate feature
turso only.Source§async fn find_by_id(&self, id: E::Id) -> DatabaseResult<Option<E>>
async fn find_by_id(&self, id: E::Id) -> DatabaseResult<Option<E>>
根据主键查找
Source§async fn find_all(&self) -> DatabaseResult<Vec<E>>
async fn find_all(&self) -> DatabaseResult<Vec<E>>
查找所有
Source§async fn delete_by_id(&self, id: E::Id) -> DatabaseResult<u64>
async fn delete_by_id(&self, id: E::Id) -> DatabaseResult<u64>
根据主键删除
Source§async fn count(&self) -> DatabaseResult<u64>
async fn count(&self) -> DatabaseResult<u64>
统计数量
Auto Trait Implementations§
impl<E> Freeze for DbRepository<E>
impl<E> !RefUnwindSafe for DbRepository<E>
impl<E> Send for DbRepository<E>
impl<E> Sync for DbRepository<E>
impl<E> Unpin for DbRepository<E>where
E: Unpin,
impl<E> UnsafeUnpin for DbRepository<E>
impl<E> !UnwindSafe for DbRepository<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
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