pub struct DeleteBuilder<'a> { /* private fields */ }
Expand description

Builder to contruct a delete command

Implementations

The same as where_clause method, useful to write more idiomatic SQL query

use sql_query_builder::DeleteBuilder;

let delete = DeleteBuilder::new()
  .delete_from("users")
  .where_clause("created_at < $1")
  .and("active = false");

Gets the current state of the DeleteBuilder and returns it as string

Prints the current state of the DeleteBuilder into console output in a more ease to read version. This method is useful to debug complex queries or just to print the generated SQL while you type

use sql_query_builder::DeleteBuilder;

let delete_query = DeleteBuilder::new()
  .delete_from("users")
  .where_clause("login = 'foo'")
  .debug()
  .where_clause("name = 'Foo'")
  .as_string();

Output

DELETE FROM users
WHERE login = 'foo'

The delete clause. This method overrides the previous value

use sql_query_builder::DeleteBuilder;

let delete = DeleteBuilder::new()
  .delete_from("orders");

let delete = DeleteBuilder::new()
  .delete_from("address")
  .delete_from("orders");

Create DeleteBuilder’s instance

Prints the current state of the DeleteBuilder into console output similar to debug method, the difference is that this method prints in one line.

Adds at the beginning a raw SQL query.

use sql_query_builder::DeleteBuilder;

let raw_query = "delete from users";
let delete_query = DeleteBuilder::new()
  .raw(raw_query)
  .where_clause("login = 'foo'")
  .as_string();

Output

delete from users
WHERE login = 'foo'

Adds a raw SQL query after a specified clause.

use sql_query_builder::{DeleteClause, DeleteBuilder};

let raw = "where name = 'Foo'";
let delete_query = DeleteBuilder::new()
  .delete_from("users")
  .raw_after(DeleteClause::DeleteFrom, raw)
  .as_string();

Output

DELETE FROM users
where name = 'Foo'

Adds a raw SQL query before a specified clause.

use sql_query_builder::{DeleteClause, DeleteBuilder};

let raw = "delete from users";
let delete_query = DeleteBuilder::new()
  .raw_before(DeleteClause::Where, raw)
  .where_clause("name = 'Bar'")
  .as_string();

Output

delete from users
WHERE name = 'Bar'

The returning clause, this method can be used enabling the feature flag postgresql

The where clause

use sql_query_builder::DeleteBuilder;

let delete = DeleteBuilder::new()
  .delete_from("users")
  .where_clause("login = 'foo'");

The with clause, this method can be used enabling the feature flag postgresql

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.