pub trait Repository<T: Model> {
type Error;
// Required methods
fn save(&self, model: &T) -> Result<T, Self::Error>;
fn find_by_id(&self, id: &T::PrimaryKey) -> Result<Option<T>, Self::Error>;
fn find_all(&self) -> Result<Vec<T>, Self::Error>;
fn delete(&self, id: &T::PrimaryKey) -> Result<bool, Self::Error>;
fn exists(&self, id: &T::PrimaryKey) -> Result<bool, Self::Error>;
}
Expand description
Repository trait providing high-level database operations for models
Required Associated Types§
Required Methods§
Sourcefn find_by_id(&self, id: &T::PrimaryKey) -> Result<Option<T>, Self::Error>
fn find_by_id(&self, id: &T::PrimaryKey) -> Result<Option<T>, Self::Error>
Get a model by its primary key