Trait atmosphere::Read

source ·
pub trait Read: Table + Bind + Hooks + Send + Sync + Unpin + 'static {
    // Required methods
    fn find<'e, 'life0, 'async_trait, E>(
        pk: &'life0 Self::PrimaryKey,
        executor: E
    ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
       where 'e: 'async_trait,
             'life0: 'async_trait,
             E: Executor<'e, Database = Postgres> + 'async_trait,
             <Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
             Self: 'async_trait;
    fn find_optional<'e, 'life0, 'async_trait, E>(
        pk: &'life0 Self::PrimaryKey,
        executor: E
    ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Error>> + Send + 'async_trait>>
       where 'e: 'async_trait,
             'life0: 'async_trait,
             E: Executor<'e, Database = Postgres> + 'async_trait,
             <Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
             Self: 'async_trait;
    fn find_all<'e, 'async_trait, E>(
        executor: E
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>
       where 'e: 'async_trait,
             E: Executor<'e, Database = Postgres> + 'async_trait,
             <Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
             Self: 'async_trait;
    fn reload<'e, 'life0, 'async_trait, E>(
        &'life0 mut self,
        executor: E
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'e: 'async_trait,
             'life0: 'async_trait,
             E: Executor<'e, Database = Postgres> + 'async_trait,
             <Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send,
             Self: 'async_trait;
}
Expand description

Trait for reading rows from a database.

This trait provides the functionality for reading data from tables in a SQL database. It defines several asynchronous methods for retrieving rows either by their primary key, reloading existing entities, or fetching all rows in a table. The trait incorporates hooks at various stages, allowing for custom logic to be executed as part of the reading process.

Required Methods§

source

fn find<'e, 'life0, 'async_trait, E>( pk: &'life0 Self::PrimaryKey, executor: E ) -> Pin<Box<dyn Future<Output = Result<Self, Error>> + Send + 'async_trait>>
where 'e: 'async_trait, 'life0: 'async_trait, E: Executor<'e, Database = Postgres> + 'async_trait, <Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send, Self: 'async_trait,

Finds and retrieves a row by its primary key. This method constructs a query to fetch a single row based on the primary key, executes it, and returns the result, optionally triggering hooks before and after execution.

source

fn find_optional<'e, 'life0, 'async_trait, E>( pk: &'life0 Self::PrimaryKey, executor: E ) -> Pin<Box<dyn Future<Output = Result<Option<Self>, Error>> + Send + 'async_trait>>
where 'e: 'async_trait, 'life0: 'async_trait, E: Executor<'e, Database = Postgres> + 'async_trait, <Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send, Self: 'async_trait,

Finds and retrieves a row by its primary key. This method constructs a query to fetch a single row based on the primary key, executes it, and returns the result, optionally triggering hooks before and after execution.

source

fn find_all<'e, 'async_trait, E>( executor: E ) -> Pin<Box<dyn Future<Output = Result<Vec<Self>, Error>> + Send + 'async_trait>>
where 'e: 'async_trait, E: Executor<'e, Database = Postgres> + 'async_trait, <Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send, Self: 'async_trait,

Retrieves all rows from the table. This method is useful for fetching the complete dataset of a table, executing a query to return all rows, and applying hooks as needed.

source

fn reload<'e, 'life0, 'async_trait, E>( &'life0 mut self, executor: E ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'e: 'async_trait, 'life0: 'async_trait, E: Executor<'e, Database = Postgres> + 'async_trait, <Postgres as HasArguments<'q>>::Arguments: for<'q> IntoArguments<'q, Postgres> + for<'q> Send, Self: 'async_trait,

Reloads the current entity from the database. This method is designed to update the entity instance with the latest data from the database, ensuring that it reflects the current state of the corresponding row.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T> Read for T
where T: Table + Bind + Hooks + Send + Sync + Unpin + 'static,