pub struct Db {
pub pool: PgPool,
pub transaction: PgTx,
}
Fields§
§pool: PgPool
§transaction: PgTx
Implementations§
Source§impl Db
impl Db
pub async fn connect(connection_string: &str) -> Result<Self>
pub async fn transaction(&self) -> Result<Self>
pub async fn execute<'a>(&self, query: PgQuery<'a>) -> Result<PgQueryResult>
pub async fn fetch_one<'a, T, F>(&self, query: PgMap<'a, F>) -> Result<T>
pub async fn fetch_all<'a, T, F>(&self, query: PgMap<'a, F>) -> Result<Vec<T>>
pub async fn fetch_optional<'a, T, F>( &self, query: PgMap<'a, F>, ) -> Result<Option<T>>
pub async fn fetch_one_scalar<'a, T>( &self, query: PgQueryScalar<'a, T>, ) -> Result<T>
pub async fn fetch_all_scalar<'a, T>( &self, query: PgQueryScalar<'a, T>, ) -> Result<Vec<T>>
pub async fn fetch_optional_scalar<'a, T>( &self, query: PgQueryScalar<'a, T>, ) -> Result<Option<T>>
pub async fn commit(&self) -> Result<()>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Db
impl !RefUnwindSafe for Db
impl Send for Db
impl Sync for Db
impl Unpin for Db
impl !UnwindSafe for Db
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