pub fn set<T>(expr: impl IntoExpr<T>) -> Assignment<T>Expand description
Replace a field’s value entirely.
For collection fields, set replaces the entire collection: all current
members are disassociated (following the same optional/required foreign key
rules as remove), then the new set is associated.
Pass an empty slice to clear the collection:
ⓘ
user.update()
.todos(stmt::set::<List<Todo>>([]))
.exec(&mut db)
.await?;For scalar fields, set is equivalent to passing a plain value (the
setter already defaults to set semantics).
§Examples
ⓘ
// Replace all todos
user.update()
.todos(stmt::set([
Todo::create().title("Only todo"),
]))
.exec(&mut db)
.await?;