pub struct PostgresClientWrapper { /* private fields */ }Expand description
A wrapper around the elefant-client connection pool, providing a convenient interface.
Implementations§
Source§impl PostgresClientWrapper
impl PostgresClientWrapper
Sourcepub async fn new(settings: PostgresConnectionSettings) -> Result<Self>
pub async fn new(settings: PostgresConnectionSettings) -> Result<Self>
Create a new PostgresClientWrapper.
This will connect to the postgres server to figure out the version of the server. If the version is less than 12, an error is returned.
Sourcepub fn pool(&self) -> &TokioPostgresPool
pub fn pool(&self) -> &TokioPostgresPool
Get a reference to the underlying pool
Sourcepub async fn execute_non_query(&self, sql: &str) -> Result
pub async fn execute_non_query(&self, sql: &str) -> Result
Execute a query that does not return any results.
Sourcepub async fn get_results<T: FromSqlRowOwned>(&self, sql: &str) -> Result<Vec<T>>
pub async fn get_results<T: FromSqlRowOwned>(&self, sql: &str) -> Result<Vec<T>>
Execute a query that returns results.
Sourcepub async fn get_result<T: FromSqlRowOwned>(&self, sql: &str) -> Result<T>
pub async fn get_result<T: FromSqlRowOwned>(&self, sql: &str) -> Result<T>
Execute a query that returns a single result.
Sourcepub async fn get_single_results<T: FromSqlOwned>(
&self,
sql: &str,
) -> Result<Vec<T>>
pub async fn get_single_results<T: FromSqlOwned>( &self, sql: &str, ) -> Result<Vec<T>>
Execute a query that returns a single column of results.
Sourcepub async fn get_single_result<T: FromSqlOwned>(&self, sql: &str) -> Result<T>
pub async fn get_single_result<T: FromSqlOwned>(&self, sql: &str) -> Result<T>
Execute a query that returns a single column of a single row of results.
Auto Trait Implementations§
impl Freeze for PostgresClientWrapper
impl RefUnwindSafe for PostgresClientWrapper
impl Send for PostgresClientWrapper
impl Sync for PostgresClientWrapper
impl Unpin for PostgresClientWrapper
impl UnsafeUnpin for PostgresClientWrapper
impl UnwindSafe for PostgresClientWrapper
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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