pub struct ForgeDb(/* private fields */);Expand description
Pool wrapper that adds db.query tracing spans to every database operation.
Returned by QueryContext::db(). Implements sqlx’s sqlx::Executor trait,
so it works as a drop-in replacement for &PgPool with compile-time
checked macros (query!, query_as!).
ⓘ
sqlx::query_as!(User, "SELECT * FROM users")
.fetch_all(ctx.db())
.await?Implementations§
Trait Implementations§
Source§impl Executor<'static> for ForgeDb
impl Executor<'static> for ForgeDb
type Database = Postgres
Source§fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<Either<PgQueryResult, PgRow>, Error>>
fn fetch_many<'e, 'q: 'e, E>( self, query: E, ) -> BoxStream<'e, Result<Either<PgQueryResult, PgRow>, Error>>
Execute multiple queries and return the generated results as a stream
from each query, in a stream.
Source§fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<PgRow>, Error>>
fn fetch_optional<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Option<PgRow>, Error>>
Execute the query and returns at most one row.
Source§fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<PgQueryResult, Error>>
fn execute<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<PgQueryResult, Error>>
Execute the query and return the total number of rows affected.
Source§fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<PgRow>, Error>>
fn fetch_all<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<Vec<PgRow>, Error>>
Execute the query and return all the generated results, collected into a
Vec.Source§fn fetch_one<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<PgRow, Error>>
fn fetch_one<'e, 'q: 'e, E>( self, query: E, ) -> BoxFuture<'e, Result<PgRow, Error>>
Execute the query and returns exactly one row.
Source§fn prepare_with<'e, 'q: 'e>(
self,
sql: &'q str,
parameters: &'e [<Postgres as Database>::TypeInfo],
) -> BoxFuture<'e, Result<<Postgres as Database>::Statement<'q>, Error>>
fn prepare_with<'e, 'q: 'e>( self, sql: &'q str, parameters: &'e [<Postgres as Database>::TypeInfo], ) -> BoxFuture<'e, Result<<Postgres as Database>::Statement<'q>, Error>>
Prepare the SQL query, with parameter type information, to inspect the
type information about its parameters and results. Read more
Source§fn execute_many<'e, 'q, E>(
self,
query: E,
) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
fn execute_many<'e, 'q, E>( self, query: E, ) -> Pin<Box<dyn Stream<Item = Result<<Self::Database as Database>::QueryResult, Error>> + Send + 'e>>
Execute multiple queries and return the rows affected from each query, in a stream.
Auto Trait Implementations§
impl Freeze for ForgeDb
impl !RefUnwindSafe for ForgeDb
impl Send for ForgeDb
impl Sync for ForgeDb
impl Unpin for ForgeDb
impl UnsafeUnpin for ForgeDb
impl !UnwindSafe for ForgeDb
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