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§
Sourcefn backend(&self) -> DatabaseBackend
fn backend(&self) -> DatabaseBackend
获取数据库后端类型
Sourcefn 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<'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,
执行查询,返回结果集
Sourcefn 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 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)
Sourcefn 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<'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,
执行语句,返回影响的行数
Sourcefn 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 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)
Sourcefn 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 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,
准备语句
Sourcefn begin_transaction<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = DatabaseResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: '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,
开始一个新事务
Provided Methods§
Sourcefn 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 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)