fletch_orm/connection.rs
1//! Connection trait for abstracting over Pool and Transaction.
2//!
3//! Rather than defining our own `Connection` trait, fletch leverages
4//! [`sqlx::Executor`] directly. The [`Executor`] re-export allows
5//! users to write functions generic over any SQLx executor (pool,
6//! connection, or transaction) without importing sqlx themselves.
7
8/// Re-export of the SQLx `Executor` trait.
9///
10/// Use this as a bound when you need a function that works with
11/// both a `Pool` and a `Transaction`:
12///
13/// ```ignore
14/// async fn my_query<'e, E>(executor: E) -> Result<(), FletchError>
15/// where
16/// E: Executor<'e, Database = Sqlite>,
17/// {
18/// sqlx::query("SELECT 1").execute(executor).await?;
19/// Ok(())
20/// }
21/// ```
22pub use sqlx::Executor;