Skip to main content

QueryExecutor

Trait QueryExecutor 

Source
pub trait QueryExecutor: Send + Sync {
    type Error: Error + Send + Sync + 'static;
    type Row: Row;

    // Required methods
    fn query(
        &self,
        sql: &str,
        params: &[&dyn ToSqlParam],
    ) -> impl Future<Output = Result<Vec<Self::Row>, Self::Error>> + Send;
    fn execute(
        &self,
        sql: &str,
        params: &[&dyn ToSqlParam],
    ) -> impl Future<Output = Result<u64, Self::Error>> + Send;
}
Expand description

Common trait for executing SQL queries, shared by both Client and Transaction.

Generated NextSQL functions accept &(impl QueryExecutor + ?Sized) so they can be called with either a client connection or inside a transaction.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Source

type Row: Row

Required Methods§

Source

fn query( &self, sql: &str, params: &[&dyn ToSqlParam], ) -> impl Future<Output = Result<Vec<Self::Row>, Self::Error>> + Send

Execute a query that returns rows.

Source

fn execute( &self, sql: &str, params: &[&dyn ToSqlParam], ) -> impl Future<Output = Result<u64, Self::Error>> + Send

Execute a statement that returns the number of affected rows.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§