pub trait Repository<T: Model + 'static>: Send + Sync {
// Required methods
fn find<'life0, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
model: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
model: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn find_by<'life0, 'async_trait>(
&'life0 self,
criteria: HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn count<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn exists<'life0, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}
Expand description
Trait for database repositories
Required Methods§
Sourcefn find<'life0, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn find<'life0, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<Option<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Finds a record by primary key
Sourcefn all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn all<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<T>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Finds all records
Sourcefn create<'life0, 'life1, 'async_trait>(
&'life0 self,
model: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn create<'life0, 'life1, 'async_trait>(
&'life0 self,
model: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Creates a new record
Sourcefn update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
model: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update<'life0, 'life1, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
model: &'life1 T,
) -> Pin<Box<dyn Future<Output = Result<T>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Updates an existing record
Sourcefn delete<'life0, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete<'life0, 'async_trait>(
&'life0 self,
id: T::PrimaryKey,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Deletes a record