Skip to main content

DocumentRepo

Trait DocumentRepo 

Source
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 type
  • Id: The ID type for the document

§Methods

  • find_all: Retrieves all documents
  • find_by_id: Retrieves a single document by ID
  • insert: Creates a new document
  • update: Updates an existing document
  • delete: Removes a document

Required Associated Types§

Source

type Id: Send + Sync + Clone + 'static

The ID type for the document

Required Methods§

Source

fn find_all(&self) -> DataFuture<'_, Result<Vec<T>, DataError>>

Retrieves all documents of type T.

Source

fn find_by_id( &self, id: Self::Id, ) -> DataFuture<'_, Result<Option<T>, DataError>>

Retrieves a single document by its ID.

Source

fn insert(&self, doc: T) -> DataFuture<'_, Result<T, DataError>>

Inserts a new document.

Source

fn update(&self, id: Self::Id, doc: T) -> DataFuture<'_, Result<T, DataError>>

Updates an existing document by ID.

Source

fn delete(&self, id: Self::Id) -> DataFuture<'_, Result<(), DataError>>

Deletes a document by ID.

Implementors§