wae_database/connection/
trait_impl.rs1use crate::connection::{config::DatabaseResult, row::DatabaseRows, statement::DatabaseStatement};
4use async_trait::async_trait;
5
6#[async_trait]
8pub trait DatabaseConnection: Send + Sync {
9 async fn query(&self, sql: &str) -> DatabaseResult<DatabaseRows>;
11
12 async fn query_with(&self, sql: &str, params: Vec<wae_types::Value>) -> DatabaseResult<DatabaseRows>;
14
15 async fn execute(&self, sql: &str) -> DatabaseResult<u64>;
17
18 async fn execute_with(&self, sql: &str, params: Vec<wae_types::Value>) -> DatabaseResult<u64>;
20
21 async fn prepare(&self, sql: &str) -> DatabaseResult<DatabaseStatement>;
23
24 #[cfg(feature = "turso")]
25 async fn query_with_turso(&self, _sql: &str, _params: Vec<turso::Value>) -> DatabaseResult<DatabaseRows> {
27 unimplemented!("query_with_turso is only implemented for Turso connections")
28 }
29
30 #[cfg(feature = "turso")]
31 async fn execute_with_turso(&self, _sql: &str, _params: Vec<turso::Value>) -> DatabaseResult<u64> {
33 unimplemented!("execute_with_turso is only implemented for Turso connections")
34 }
35}