pub enum MiddlewarePoolConnection {
Postgres {
client: Object,
translate_placeholders: bool,
},
Sqlite {
conn: SqliteConnection,
translate_placeholders: bool,
},
}Variants§
Implementations§
Source§impl MiddlewarePoolConnection
impl MiddlewarePoolConnection
Sourcepub async fn execute_batch(
&mut self,
query: &str,
) -> Result<(), SqlMiddlewareDbError>
pub async fn execute_batch( &mut self, query: &str, ) -> Result<(), SqlMiddlewareDbError>
Executes a batch of SQL queries within a transaction by delegating to the specific database module.
§Errors
Returns an error if the selected backend cannot execute the batch or the database responds with an error.
Sourcepub fn query<'a>(&'a mut self, query: &'a str) -> QueryBuilder<'a, 'a>
pub fn query<'a>(&'a mut self, query: &'a str) -> QueryBuilder<'a, 'a>
Start a fluent query builder that can translate placeholders before executing.
Source§impl MiddlewarePoolConnection
impl MiddlewarePoolConnection
Sourcepub async fn with_sqlite_connection<F, R>(
&mut self,
func: F,
) -> Result<R, SqlMiddlewareDbError>where
F: FnOnce(&mut Connection) -> Result<R, SqlMiddlewareDbError> + Send + 'static,
R: Send + 'static,
pub async fn with_sqlite_connection<F, R>(
&mut self,
func: F,
) -> Result<R, SqlMiddlewareDbError>where
F: FnOnce(&mut Connection) -> Result<R, SqlMiddlewareDbError> + Send + 'static,
R: Send + 'static,
Run synchronous SQLite work on the underlying worker-owned connection.
§Errors
Returns SqlMiddlewareDbError::Unimplemented when the connection is not SQLite.
Sourcepub async fn prepare_sqlite_statement(
&mut self,
query: &str,
) -> Result<SqlitePreparedStatement, SqlMiddlewareDbError>
pub async fn prepare_sqlite_statement( &mut self, query: &str, ) -> Result<SqlitePreparedStatement, SqlMiddlewareDbError>
Prepare a SQLite statement and obtain a reusable handle backed by the worker thread.
§Errors
Returns SqlMiddlewareDbError::Unimplemented when the underlying connection is not
SQLite, or propagates any preparation error reported by the worker thread.
Sourcepub fn translation_default(&self) -> bool
pub fn translation_default(&self) -> bool
Pool-default translation toggle attached to this connection.
Source§impl MiddlewarePoolConnection
impl MiddlewarePoolConnection
Sourcepub async fn interact_async<F, Fut>(
&mut self,
func: F,
) -> Result<Fut::Output, SqlMiddlewareDbError>where
F: FnOnce(AnyConnWrapper<'_>) -> Fut + Send + 'static,
Fut: Future<Output = Result<(), SqlMiddlewareDbError>> + Send + 'static,
pub async fn interact_async<F, Fut>(
&mut self,
func: F,
) -> Result<Fut::Output, SqlMiddlewareDbError>where
F: FnOnce(AnyConnWrapper<'_>) -> Fut + Send + 'static,
Fut: Future<Output = Result<(), SqlMiddlewareDbError>> + Send + 'static,
Interact with the connection asynchronously
§Errors
Returns SqlMiddlewareDbError::Unimplemented for unsupported database types.
Sourcepub async fn interact_sync<F, R>(&self, f: F) -> Result<R, SqlMiddlewareDbError>
pub async fn interact_sync<F, R>(&self, f: F) -> Result<R, SqlMiddlewareDbError>
Interact with the connection synchronously
§Errors
Returns SqlMiddlewareDbError::Unimplemented for unsupported database types.