pub struct DeleteQuery<'a, 'c> {
pub whre: Vec<WhereClause<'a, 'c>>,
/* private fields */
}
Expand description
Struct representing a SQL Delete Statement
Fields§
§whre: Vec<WhereClause<'a, 'c>>
Implementations§
Source§impl<'a, 'c> DeleteQuery<'a, 'c>
impl<'a, 'c> DeleteQuery<'a, 'c>
Sourcepub fn from(table: &'a str) -> DeleteQuery<'_, '_>
pub fn from(table: &'a str) -> DeleteQuery<'_, '_>
Return a new DeleteQuery
that deletes data from table table
Sourcepub fn limit(&mut self, limit: usize)
pub fn limit(&mut self, limit: usize)
Sets the limit of items to delete
§Example
use query_builder::{DeleteQuery, Value, WhereClause};
let mut query = DeleteQuery::from("users");
// add values to delete
query.whre.push(WhereClause::new("name", Value::Varchar("gregory"), None));
// add the limit
query.limit(1);
// make sure the query looks like expected
assert_eq!(query.as_string(), "DELETE FROM users WHERE name = 'gregory' LIMIT 1");
Sourcepub fn get_limit(&self) -> Option<usize>
pub fn get_limit(&self) -> Option<usize>
Returns the limit of the DeleteQuery
§Example
use query_builder::{DeleteQuery, Value};
// create query
let mut query = DeleteQuery::from("users");
// set the limit
query.limit(12);
assert_eq!(query.get_limit(), Some(12));
Sourcepub fn clear_limit(&mut self)
pub fn clear_limit(&mut self)
Removes the limit from the DeleteQuery
§Example
use query_builder::DeleteQuery;
let mut query = DeleteQuery::from("users");
/* add limit to the query */
query.limit(12);
assert_eq!(query.get_limit(), Some(12));
/* clear the limit */
query.clear_limit();
assert_eq!(query.get_limit(), None);
Sourcepub fn is_ordered(&self) -> bool
pub fn is_ordered(&self) -> bool
Returns either true
or false
depending on whether
or not the DeleteQuery
contains a OrderBy
clause
§Example
use query_builder::{DeleteQuery, OrderBy};
let mut query = DeleteQuery::from("states");
query.order_by(OrderBy::Row("population"));
assert!(query.is_ordered());
Sourcepub fn clear_order_by(&mut self)
pub fn clear_order_by(&mut self)
Removes the ORDER BY clause from the query
Sourcepub fn as_string(&self) -> String
pub fn as_string(&self) -> String
Return a String
representing the DeleteQuery
§Example
use query_builder::{DeleteQuery, Value, WhereClause, Condition};
// create basic query
let mut query = DeleteQuery::from("people");
// set parameter of the query
query.whre.push(WhereClause::new("name", Value::Varchar("justine"), None));
query.whre.push(WhereClause::new("age", Value::Int(24), Some(Condition::And)));
query.limit(1);
assert_eq!(query.as_string(), "DELETE FROM people WHERE name = 'justine' AND age = 24 LIMIT 1");
Trait Implementations§
Source§impl<'a, 'c> Debug for DeleteQuery<'a, 'c>
impl<'a, 'c> Debug for DeleteQuery<'a, 'c>
Source§impl<'a, 'c> Display for DeleteQuery<'a, 'c>
impl<'a, 'c> Display for DeleteQuery<'a, 'c>
Auto Trait Implementations§
impl<'a, 'c> Freeze for DeleteQuery<'a, 'c>
impl<'a, 'c> RefUnwindSafe for DeleteQuery<'a, 'c>
impl<'a, 'c> Send for DeleteQuery<'a, 'c>
impl<'a, 'c> Sync for DeleteQuery<'a, 'c>
impl<'a, 'c> Unpin for DeleteQuery<'a, 'c>
impl<'a, 'c> UnwindSafe for DeleteQuery<'a, 'c>
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