Skip to main content

DatabaseConnection

Trait DatabaseConnection 

Source
pub trait DatabaseConnection: Send + Sync {
    // Required methods
    fn backend(&self) -> DatabaseBackend;
    fn query<'life0, 'life1, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<DatabaseRows>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn query_with<'life0, 'life1, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
        params: Vec<Value>,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<DatabaseRows>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn execute_with<'life0, 'life1, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
        params: Vec<Value>,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn prepare<'life0, 'life1, 'async_trait>(
        &'life0 self,
        sql: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<DatabaseStatement>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn begin_transaction<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn commit<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn rollback<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn query_with_turso<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _sql: &'life1 str,
        _params: Vec<Value>,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<DatabaseRows>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn execute_with_turso<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _sql: &'life1 str,
        _params: Vec<Value>,
    ) -> Pin<Box<dyn Future<Output = DatabaseResult<u64>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

数据库连接抽象

Required Methods§

Source

fn backend(&self) -> DatabaseBackend

获取数据库后端类型

Source

fn query<'life0, 'life1, 'async_trait>( &'life0 self, sql: &'life1 str, ) -> Pin<Box<dyn Future<Output = DatabaseResult<DatabaseRows>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

执行查询,返回结果集

Source

fn query_with<'life0, 'life1, 'async_trait>( &'life0 self, sql: &'life1 str, params: Vec<Value>, ) -> Pin<Box<dyn Future<Output = DatabaseResult<DatabaseRows>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

执行带参数的查询 (使用 wae_types::Value)

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, sql: &'life1 str, ) -> Pin<Box<dyn Future<Output = DatabaseResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

执行语句,返回影响的行数

Source

fn execute_with<'life0, 'life1, 'async_trait>( &'life0 self, sql: &'life1 str, params: Vec<Value>, ) -> Pin<Box<dyn Future<Output = DatabaseResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

执行带参数的语句 (使用 wae_types::Value)

Source

fn prepare<'life0, 'life1, 'async_trait>( &'life0 self, sql: &'life1 str, ) -> Pin<Box<dyn Future<Output = DatabaseResult<DatabaseStatement>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

准备语句

Source

fn begin_transaction<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = DatabaseResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

开始一个新事务

Source

fn commit<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = DatabaseResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

提交当前事务

Source

fn rollback<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = DatabaseResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

回滚当前事务

Provided Methods§

Source

fn query_with_turso<'life0, 'life1, 'async_trait>( &'life0 self, _sql: &'life1 str, _params: Vec<Value>, ) -> Pin<Box<dyn Future<Output = DatabaseResult<DatabaseRows>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

执行带参数的查询 (内部使用 turso::Value)

Source

fn execute_with_turso<'life0, 'life1, 'async_trait>( &'life0 self, _sql: &'life1 str, _params: Vec<Value>, ) -> Pin<Box<dyn Future<Output = DatabaseResult<u64>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

执行带参数的语句 (内部使用 turso::Value)

Implementors§