Function diesel::delete [] [src]

pub fn delete<T: IntoUpdateTarget>(source: T)
                                   -> DeleteStatement<T::Table, T::WhereClause>

Creates a delete statement. Will delete the records in the given set. Because this function has a very generic name, it is not exported by default.

Examples

Deleting a single record:

let old_count = get_count();
try!(diesel::delete(users.filter(id.eq(1))).execute(&connection));
assert_eq!(old_count.map(|count| count - 1), get_count());

Deleting a whole table:

try!(diesel::delete(users).execute(&connection));
assert_eq!(Ok(0), get_count());