pub trait ConnectionTrait: Sync {
    fn get_database_backend(&self) -> DbBackend;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        stmt: Statement
    ) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn execute_unprepared<'life0, 'life1, 'async_trait>(
        &'life0 self,
        sql: &'life1 str
    ) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait
; fn query_one<'life0, 'async_trait>(
        &'life0 self,
        stmt: Statement
    ) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn query_all<'life0, 'async_trait>(
        &'life0 self,
        stmt: Statement
    ) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>
    where
        Self: 'async_trait,
        'life0: 'async_trait
; fn support_returning(&self) -> bool { ... } fn is_mock_connection(&self) -> bool { ... } }
Expand description

The generic API for a database connection that can perform query or execute statements. It abstracts database connection and transaction

Required Methods§

source

fn get_database_backend(&self) -> DbBackend

Fetch the database backend as specified in DbBackend. This depends on feature flags enabled.

source

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

Execute a Statement

source

fn execute_unprepared<'life0, 'life1, 'async_trait>(
    &'life0 self,
    sql: &'life1 str
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,

Execute a unprepared Statement

source

fn query_one<'life0, 'async_trait>(
    &'life0 self,
    stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,

Execute a Statement and return a query

source

fn query_all<'life0, 'async_trait>(
    &'life0 self,
    stmt: Statement
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
    Self: 'async_trait,
    'life0: 'async_trait,

Execute a Statement and return a collection Vec<QueryResult> on success

Provided Methods§

source

fn support_returning(&self) -> bool

Check if the connection supports RETURNING syntax on insert and update

source

fn is_mock_connection(&self) -> bool

Check if the connection is a test connection for the Mock database

Implementors§