use crate::connection::{config::DatabaseResult, row::DatabaseRows, statement::DatabaseStatement};
use async_trait::async_trait;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DatabaseBackend {
Limbo,
Postgres,
MySql,
}
#[async_trait]
pub trait DatabaseConnection: Send + Sync {
fn backend(&self) -> DatabaseBackend;
async fn query(&self, sql: &str) -> DatabaseResult<DatabaseRows>;
async fn query_with(&self, sql: &str, params: Vec<wae_types::Value>) -> DatabaseResult<DatabaseRows>;
async fn execute(&self, sql: &str) -> DatabaseResult<u64>;
async fn execute_with(&self, sql: &str, params: Vec<wae_types::Value>) -> DatabaseResult<u64>;
async fn prepare(&self, sql: &str) -> DatabaseResult<DatabaseStatement>;
async fn begin_transaction(&self) -> DatabaseResult<()>;
async fn commit(&self) -> DatabaseResult<()>;
async fn rollback(&self) -> DatabaseResult<()>;
#[cfg(feature = "limbo")]
async fn query_with_limbo(&self, _sql: &str, _params: Vec<limbo::Value>) -> DatabaseResult<DatabaseRows> {
unimplemented!("query_with_limbo is only implemented for Limbo connections")
}
#[cfg(feature = "limbo")]
async fn execute_with_limbo(&self, _sql: &str, _params: Vec<limbo::Value>) -> DatabaseResult<u64> {
unimplemented!("execute_with_limbo is only implemented for Limbo connections")
}
}