pub struct NamedParams { /* private fields */ }Expand description
Named parameters for SQL queries
This struct holds named parameter bindings that can be used with
the :name syntax in SQL queries.
§Examples
ⓘ
use stoolap::{Database, NamedParams, named_params};
let db = Database::open("memory://")?;
db.execute("CREATE TABLE users (id INTEGER, name TEXT)", ())?;
// Using the named_params! macro
db.execute_named(
"INSERT INTO users VALUES (:id, :name)",
named_params!{ id: 1, name: "Alice" }
)?;
// Building NamedParams manually
let params = NamedParams::new()
.add("id", 2)
.add("name", "Bob");
db.execute_named("INSERT INTO users VALUES (:id, :name)", params)?;Implementations§
Source§impl NamedParams
impl NamedParams
Sourcepub fn add<T: ToParam>(self, name: impl Into<String>, value: T) -> Self
pub fn add<T: ToParam>(self, name: impl Into<String>, value: T) -> Self
Add a named parameter (builder style)
Sourcepub fn insert<T: ToParam>(&mut self, name: impl Into<String>, value: T)
pub fn insert<T: ToParam>(&mut self, name: impl Into<String>, value: T)
Insert a named parameter
Sourcepub fn into_inner(self) -> FxHashMap<String, Value>
pub fn into_inner(self) -> FxHashMap<String, Value>
Get the underlying FxHashMap
Trait Implementations§
Source§impl Clone for NamedParams
impl Clone for NamedParams
Source§fn clone(&self) -> NamedParams
fn clone(&self) -> NamedParams
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NamedParams
impl Debug for NamedParams
Source§impl Default for NamedParams
impl Default for NamedParams
Source§fn default() -> NamedParams
fn default() -> NamedParams
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for NamedParams
impl RefUnwindSafe for NamedParams
impl Send for NamedParams
impl Sync for NamedParams
impl Unpin for NamedParams
impl UnwindSafe for NamedParams
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