pub trait Repo<T>: Send + Syncwhere
T: EntityMeta,{
// Required methods
fn find_all(&self) -> RepoFuture<'_, Result<Vec<T>, OrmError>>;
fn find_by_id(
&self,
id: T::Id,
) -> RepoFuture<'_, Result<Option<T>, OrmError>>;
fn create(&self, entity: T) -> RepoFuture<'_, Result<T, OrmError>>;
fn update_by_id(
&self,
id: T::Id,
entity: T,
) -> RepoFuture<'_, Result<T, OrmError>>;
fn delete_by_id(&self, id: T::Id) -> RepoFuture<'_, Result<(), OrmError>>;
}Expand description
Repo Trait
A trait for implementing SQL repositories in NestForge. Provides standard CRUD operations for database entities.
§Type Parameters
T: The entity type (must implement EntityMeta)
§Methods
find_all: Retrieves all entitiesfind_by_id: Retrieves a single entity by IDcreate: Creates a new entityupdate_by_id: Updates an existing entitydelete_by_id: Removes an entity
Required Methods§
Sourcefn find_all(&self) -> RepoFuture<'_, Result<Vec<T>, OrmError>>
fn find_all(&self) -> RepoFuture<'_, Result<Vec<T>, OrmError>>
Retrieves all entities of type T.
Sourcefn find_by_id(&self, id: T::Id) -> RepoFuture<'_, Result<Option<T>, OrmError>>
fn find_by_id(&self, id: T::Id) -> RepoFuture<'_, Result<Option<T>, OrmError>>
Retrieves a single entity by its ID.
Sourcefn create(&self, entity: T) -> RepoFuture<'_, Result<T, OrmError>>
fn create(&self, entity: T) -> RepoFuture<'_, Result<T, OrmError>>
Creates a new entity in the database.
Sourcefn update_by_id(
&self,
id: T::Id,
entity: T,
) -> RepoFuture<'_, Result<T, OrmError>>
fn update_by_id( &self, id: T::Id, entity: T, ) -> RepoFuture<'_, Result<T, OrmError>>
Updates an existing entity by ID.
Sourcefn delete_by_id(&self, id: T::Id) -> RepoFuture<'_, Result<(), OrmError>>
fn delete_by_id(&self, id: T::Id) -> RepoFuture<'_, Result<(), OrmError>>
Deletes an entity by ID.