Skip to main content

UpdateModel

Derive Macro UpdateModel 

Source
#[derive(UpdateModel)]
{
    // Attributes available to this derive:
    #[orm]
}
Expand description

Derive UpdateModel helpers for updating a table (patch-style).

ยงAttributes

Struct-level:

  • #[orm(table = "name")] - Specify table name (required)
  • One of:
    • #[orm(id_column = "id")] - Explicit primary key column
    • #[orm(model = "TypePath")] - Derive primary key column from a Model
    • #[orm(returning = "TypePath")] where TypePath::ID exists
  • #[orm(returning = "TypePath")] - Enable update_by_id_returning helpers (optional)
  • Multi-table write graphs (advanced): see docs/design/multi-table-writes-final.md.

Field-level:

  • #[orm(skip_update)] - Never include this field in UPDATE
  • #[orm(default)] - Use SQL DEFAULT for this field
  • #[orm(auto_now)] - Use NOW() for this field on update
  • #[orm(column = "name")] / #[orm(table = "name")] - Override column/table mapping (optional)