pub struct Query { /* private fields */ }Expand description
A query: its text, an id, and the values of its {name:Type}
parameters.
Implementations§
Source§impl Query
impl Query
pub fn new(sql: impl AsRef<str>) -> Self
pub fn id(self, id: impl AsRef<str>) -> Self
Sourcepub fn param(self, name: impl Into<String>, value: impl Into<Value>) -> Self
pub fn param(self, name: impl Into<String>, value: impl Into<Value>) -> Self
Binds value to the {name:Type} placeholders of the query, which
the server fills in: the value is sent as the text the server parses
for Type, never spliced into the SQL. Binding a name again replaces
its value. A parameter of a Nullable type that is not bound is NULL.
let mut client = pool.get_handle().await?;
let query = Query::new("SELECT name FROM users WHERE id = {id:UInt32} AND city = {city:String}")
.param("id", 42_u32)
.param("city", "O'Fallon");
let block = client.query(query).fetch_all().await?;Trait Implementations§
Auto Trait Implementations§
impl Forget for Query
impl Freeze for Query
impl Move for Query
impl RefUnwindSafe for Query
impl Send for Query
impl Sync for Query
impl Unpin for Query
impl UnsafeUnpin for Querywhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<(String, Value)>: UnsafeUnpin,
impl UnwindSafe for Querywhere
RawVecInner: UnwindSafe,
Arc<Vec<u8>>: UnwindSafe,
NonZero<i32>: UnwindSafe,
TzOffset: UnwindSafe,
&'static SqlType: UnwindSafe,
BoxRaw<Value>: UnwindSafe,
Arc<Vec<Value>>: UnwindSafe,
Arc<HashMap<Value, Value>>: UnwindSafe,
Arc<Vec<(String, Value)>>: UnwindSafe,
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> 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