pub trait DocumentRepo<T>: Send + Sync {
type Id: Send + Sync + Clone + 'static;
// Required methods
fn find_all(&self) -> DataFuture<'_, Result<Vec<T>, DataError>>;
fn find_by_id(
&self,
id: Self::Id,
) -> DataFuture<'_, Result<Option<T>, DataError>>;
fn insert(&self, doc: T) -> DataFuture<'_, Result<T, DataError>>;
fn update(
&self,
id: Self::Id,
doc: T,
) -> DataFuture<'_, Result<T, DataError>>;
fn delete(&self, id: Self::Id) -> DataFuture<'_, Result<(), DataError>>;
}Expand description
DocumentRepo Trait
A trait for implementing document repositories in NestForge. Provides standard CRUD operations for entities.
§Type Parameters
T: The document/entity typeId: The ID type for the document
§Methods
find_all: Retrieves all documentsfind_by_id: Retrieves a single document by IDinsert: Creates a new documentupdate: Updates an existing documentdelete: Removes a document
Required Associated Types§
Required Methods§
Sourcefn find_all(&self) -> DataFuture<'_, Result<Vec<T>, DataError>>
fn find_all(&self) -> DataFuture<'_, Result<Vec<T>, DataError>>
Retrieves all documents of type T.
Sourcefn find_by_id(
&self,
id: Self::Id,
) -> DataFuture<'_, Result<Option<T>, DataError>>
fn find_by_id( &self, id: Self::Id, ) -> DataFuture<'_, Result<Option<T>, DataError>>
Retrieves a single document by its ID.
Sourcefn insert(&self, doc: T) -> DataFuture<'_, Result<T, DataError>>
fn insert(&self, doc: T) -> DataFuture<'_, Result<T, DataError>>
Inserts a new document.