Function scooby::postgres::statements::delete_from
source · pub fn delete_from(table_name: impl Into<TableName>) -> DeleteFrom
Expand description
Create a new DELETE FROM
statement with the given table name.
Returns a DeleteFrom
structure that allows adding additional clauses. Call to_string
to finalize and get SQL.
Supported clauses
Specifying a WITH
clause
To create a DELETE FROM
statement with a WITH
clause, start with with
instead of this function.
Examples
use scooby::postgres::delete_from;
let sql = delete_from("Dummy").to_string();
assert_eq!(sql, "DELETE FROM Dummy");
use scooby::postgres::delete_from;
let sql = delete_from("Dummy")
.where_("x > 0")
.where_("y < 10")
.returning("id")
.to_string();
assert_eq!(sql, "DELETE FROM Dummy WHERE x > 0 AND y < 10 RETURNING id");