pub struct Sql { /* private fields */ }Expand description
A statement built by sql().
Implementations§
Source§impl Sql
impl Sql
Sourcepub fn bind_all(self, values: impl IntoIterator<Item = DbValue>) -> Self
pub fn bind_all(self, values: impl IntoIterator<Item = DbValue>) -> Self
Binds several values in order.
Sourcepub async fn fetch_all<'c>(
self,
db: impl Executor<'c>,
) -> Result<Vec<Row>, DbError>
pub async fn fetch_all<'c>( self, db: impl Executor<'c>, ) -> Result<Vec<Row>, DbError>
Runs the statement and returns every row.
Sourcepub async fn fetch_optional<'c>(
self,
db: impl Executor<'c>,
) -> Result<Option<Row>, DbError>
pub async fn fetch_optional<'c>( self, db: impl Executor<'c>, ) -> Result<Option<Row>, DbError>
Runs the statement and returns the first row, if any.
Sourcepub async fn fetch_one<'c>(self, db: impl Executor<'c>) -> Result<Row, DbError>
pub async fn fetch_one<'c>(self, db: impl Executor<'c>) -> Result<Row, DbError>
The first row; an error if there is none.
Sourcepub async fn execute<'c>(self, db: impl Executor<'c>) -> Result<u64, DbError>
pub async fn execute<'c>(self, db: impl Executor<'c>) -> Result<u64, DbError>
Runs the statement and returns the number of rows it changed.
Sourcepub async fn fetch_as<'c, T: FromRow>(
self,
db: impl Executor<'c>,
) -> Result<Vec<T>, DbError>
pub async fn fetch_as<'c, T: FromRow>( self, db: impl Executor<'c>, ) -> Result<Vec<T>, DbError>
Every row, read into T: a model, a #[derive(FromRow)] struct or a
tuple; see super::FromRow.
Sourcepub async fn fetch_optional_as<'c, T: FromRow>(
self,
db: impl Executor<'c>,
) -> Result<Option<T>, DbError>
pub async fn fetch_optional_as<'c, T: FromRow>( self, db: impl Executor<'c>, ) -> Result<Option<T>, DbError>
The first row read into T, or None if there is no row.
Sourcepub async fn fetch_one_as<'c, T: FromRow>(
self,
db: impl Executor<'c>,
) -> Result<T, DbError>
pub async fn fetch_one_as<'c, T: FromRow>( self, db: impl Executor<'c>, ) -> Result<T, DbError>
The first row read into T; an error if there is none.
Sourcepub async fn scalar<'c, T: FromDb>(
self,
db: impl Executor<'c>,
) -> Result<T, DbError>
pub async fn scalar<'c, T: FromDb>( self, db: impl Executor<'c>, ) -> Result<T, DbError>
The first column of the first row; an error if there is no row.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Sql
impl RefUnwindSafe for Sql
impl Send for Sql
impl Sync for Sql
impl Unpin for Sql
impl UnsafeUnpin for Sql
impl UnwindSafe for Sql
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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