Skip to main content

DatabaseExecutor

Trait DatabaseExecutor 

Source
pub trait DatabaseExecutor:
    Debug
    + Sync
    + Send {
    // Required methods
    fn name() -> &'static str;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        statement: Statement,
    ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_one<'life0, 'async_trait>(
        &'life0 self,
        statement: Statement,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Column>>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn fetch_all<'life0, 'async_trait>(
        &'life0 self,
        statement: Statement,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Column>>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn pluck<'life0, 'async_trait>(
        &'life0 self,
        statement: Statement,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Column>, Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn batch<'life0, 'async_trait>(
        &'life0 self,
        statement: Statement,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Database Executor

This trait defines the expectations of a database execution

Required Methods§

Source

fn name() -> &'static str

Database driver name

Source

fn execute<'life0, 'async_trait>( &'life0 self, statement: Statement, ) -> Pin<Box<dyn Future<Output = Result<usize, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Executes a query and returns the affected rows

Source

fn fetch_one<'life0, 'async_trait>( &'life0 self, statement: Statement, ) -> Pin<Box<dyn Future<Output = Result<Option<Vec<Column>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Runs the query and returns the first row or None

Source

fn fetch_all<'life0, 'async_trait>( &'life0 self, statement: Statement, ) -> Pin<Box<dyn Future<Output = Result<Vec<Vec<Column>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Runs the query and returns the first row or None

Source

fn pluck<'life0, 'async_trait>( &'life0 self, statement: Statement, ) -> Pin<Box<dyn Future<Output = Result<Option<Column>, Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetches the first row and column from a query

Source

fn batch<'life0, 'async_trait>( &'life0 self, statement: Statement, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Batch execution

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<DB, W> DatabaseExecutor for ConnectionWithTransaction<DB, W>
where DB: DatabaseConnector, W: Debug + Deref<Target = DB> + DerefMut<Target = DB> + Send + Sync + 'static,