pub enum DatabaseClient {
Postgres(PgPool),
}Expand description
The database client, wrapping an sqlx connection pool.
Supports PostgreSQL and SQLite via feature flags.
Variants§
Implementations§
Source§impl DatabaseClient
impl DatabaseClient
Sourcepub async fn connect_postgres(url: &str) -> Result<Self, FerriormError>
pub async fn connect_postgres(url: &str) -> Result<Self, FerriormError>
Connect to a PostgreSQL database.
Sourcepub async fn connect(url: &str) -> Result<Self, FerriormError>
pub async fn connect(url: &str) -> Result<Self, FerriormError>
Connect by auto-detecting the database type from the URL.
Sourcepub async fn disconnect(self)
pub async fn disconnect(self)
Close the connection pool.
Sourcepub async fn fetch_all_pg<'q, T>(
&self,
qb: QueryBuilder<'q, Postgres>,
) -> Result<Vec<T>, FerriormError>
pub async fn fetch_all_pg<'q, T>( &self, qb: QueryBuilder<'q, Postgres>, ) -> Result<Vec<T>, FerriormError>
Execute a query builder against the appropriate pool, returning all rows.
pub async fn fetch_optional_pg<'q, T>( &self, qb: QueryBuilder<'q, Postgres>, ) -> Result<Option<T>, FerriormError>
pub async fn fetch_one_pg<'q, T>( &self, qb: QueryBuilder<'q, Postgres>, ) -> Result<T, FerriormError>
pub async fn execute_pg<'q>( &self, qb: QueryBuilder<'q, Postgres>, ) -> Result<u64, FerriormError>
Trait Implementations§
Source§impl Clone for DatabaseClient
impl Clone for DatabaseClient
Source§fn clone(&self) -> DatabaseClient
fn clone(&self) -> DatabaseClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for DatabaseClient
impl !RefUnwindSafe for DatabaseClient
impl Send for DatabaseClient
impl Sync for DatabaseClient
impl Unpin for DatabaseClient
impl UnsafeUnpin for DatabaseClient
impl !UnwindSafe for DatabaseClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more