Trait ConnectionTrait
pub trait ConnectionTrait: Sync {
// Required methods
fn get_database_backend(&self) -> DbBackend;
fn execute_raw<'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_raw<'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_raw<'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 get_schema(&self) -> Option<&str>;
// Provided methods
fn execute<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>
where S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn query_one<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>
where S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn query_all<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>
where S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: '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§
fn get_database_backend(&self) -> DbBackend
fn get_database_backend(&self) -> DbBackend
Get the database backend for the connection. This depends on feature flags enabled.
fn execute_raw<'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_raw<'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
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 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
fn query_one_raw<'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_one_raw<'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 single row of QueryResult
fn query_all_raw<'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 query_all_raw<'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 vector of QueryResult
fn get_schema(&self) -> Option<&str>
fn get_schema(&self) -> Option<&str>
For MSSQL only. Get database schema that’s specified in the connection string (the ?currentSchema=xxx part).
Provided Methods§
fn execute<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<ExecResult, DbErr>> + Send + 'async_trait>>where
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a [QueryStatement]
fn query_one<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query_one<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Option<QueryResult>, DbErr>> + Send + 'async_trait>>where
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a [QueryStatement] and return a single row of QueryResult
fn query_all<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn query_all<'life0, 'life1, 'async_trait, S>(
&'life0 self,
stmt: &'life1 S,
) -> Pin<Box<dyn Future<Output = Result<Vec<QueryResult>, DbErr>> + Send + 'async_trait>>where
S: 'async_trait + StatementBuilder,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute a [QueryStatement] and return a vector of QueryResult
fn support_returning(&self) -> bool
fn support_returning(&self) -> bool
Check if the connection supports RETURNING syntax on insert and update
fn is_mock_connection(&self) -> bool
fn is_mock_connection(&self) -> bool
Check if the connection is a test connection for the Mock database
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.