pub struct InsertQuery<'a> {
pub values: BTreeMap<&'a str, Value<'a>>,
/* private fields */
}
Expand description
Struct representing an SQL Insert Statement
Creating a query that works requires at least to function calls.
§Examples
use query_builder::{InsertQuery, Value};
// construct the InsertQuery to insert into table 'users'
let mut q = InsertQuery::into("users");
// add the value 'jonathan' to be added into the row 'name'
q.values.insert("name", Value::Varchar("jonathan"));
assert_eq!(q.as_string(), "INSERT INTO users(name) VALUES('jonathan')");
Fields§
§values: BTreeMap<&'a str, Value<'a>>
A map of the values to inserted into the table. The map is intended to be <row, value>
Implementations§
Source§impl<'a> InsertQuery<'a>
impl<'a> InsertQuery<'a>
Sourcepub fn into(table: &'a str) -> InsertQuery<'a>
pub fn into(table: &'a str) -> InsertQuery<'a>
Creates a new InsertQuery
that puts data into table
.
Sourcepub fn as_string(&self) -> String
pub fn as_string(&self) -> String
Returns a String
that represents the InsertQuery
in a valid SQL statement
§Example
use query_builder::{Value, InsertQuery};
let mut q = InsertQuery::into("users");
q.values.insert("name", Value::Varchar("greg"));
assert_eq!(q.as_string(), "INSERT INTO users(name) VALUES('greg')")
Trait Implementations§
Source§impl<'a> Debug for InsertQuery<'a>
impl<'a> Debug for InsertQuery<'a>
Source§impl<'a> Display for InsertQuery<'a>
impl<'a> Display for InsertQuery<'a>
Auto Trait Implementations§
impl<'a> Freeze for InsertQuery<'a>
impl<'a> RefUnwindSafe for InsertQuery<'a>
impl<'a> Send for InsertQuery<'a>
impl<'a> Sync for InsertQuery<'a>
impl<'a> Unpin for InsertQuery<'a>
impl<'a> UnwindSafe for InsertQuery<'a>
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