pub trait Repository<Entity, Id> {
// Required methods
fn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: Id,
) -> Pin<Box<dyn Future<Output = Result<Option<Entity>, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn find_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn insert<'life0, 'async_trait>(
&'life0 self,
entity: Entity,
) -> Pin<Box<dyn Future<Output = Result<Entity, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn update<'life0, 'async_trait>(
&'life0 self,
id: Id,
entity: Entity,
) -> Pin<Box<dyn Future<Output = Result<Entity, AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'async_trait>(
&'life0 self,
id: Id,
) -> Pin<Box<dyn Future<Output = Result<(), AppError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
Core Repository Trait This is the equivalent of the base repository in TypeORM/NestJS. Implementations (like SeaORM or Mongo) will implement this trait for specific entities.
Required Methods§
Sourcefn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: Id,
) -> Pin<Box<dyn Future<Output = Result<Option<Entity>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find_by_id<'life0, 'async_trait>(
&'life0 self,
id: Id,
) -> Pin<Box<dyn Future<Output = Result<Option<Entity>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Finds a single entity by its primary key
Sourcefn find_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find_all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Entity>, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Finds all entities
Sourcefn insert<'life0, 'async_trait>(
&'life0 self,
entity: Entity,
) -> Pin<Box<dyn Future<Output = Result<Entity, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn insert<'life0, 'async_trait>(
&'life0 self,
entity: Entity,
) -> Pin<Box<dyn Future<Output = Result<Entity, AppError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Inserts a new entity
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".