Function diesel::update [] [src]

pub fn update<T: IntoUpdateTarget>(
    source: T
) -> IncompleteUpdateStatement<T::Table, T::WhereClause>

Creates an update statement. Helpers for updating a single row can be generated by deriving AsChangeset


let updated_row = diesel::update(users.filter(id.eq(1)))
// On backends that support it, you can call `get_result` instead of `execute`
// to have `RETURNING *` automatically appended to the query. Alternatively, you
// can explicitly return an expression by using the `returning` method before
// getting the result.
assert_eq!(Ok((1, "James".to_string())), updated_row);

To update multiple columns, give set a tuple argument:

let updated_row = diesel::update(users.filter(id.eq(1)))
    .set((name.eq("James"), surname.eq("Bond")))

assert_eq!(Ok((1, "James".to_string(), "Bond".to_string())), updated_row);