#[derive(InsertModel)]
{
// Attributes available to this derive:
#[orm]
}
Expand description
Derive InsertModel helpers for inserting into a table.
ยงAttributes
Struct-level:
#[orm(table = "name")]- Specify table name (required)#[orm(returning = "TypePath")]- Enableinsert_returninghelpers (optional)- Conflict handling (Postgres
ON CONFLICT):#[orm(conflict_target = "col1,col2")]- conflict target columns (optional)#[orm(conflict_constraint = "constraint_name")]- conflict constraint (optional)#[orm(conflict_update = "col1,col2")]- columns to update on conflict (optional)
- Multi-table write graphs (advanced): function-style attrs like
#[orm(has_many(...))],#[orm(belongs_to(...))],#[orm(before_insert(...))]. Seedocs/design/multi-table-writes-final.md.
Field-level:
#[orm(id)]- Mark field as primary key (optional)#[orm(skip_insert)]- Never include this field in INSERT#[orm(default)]- Use SQLDEFAULTfor this field#[orm(auto_now_add)]- UseNOW()for this field on insert#[orm(column = "name")]/#[orm(table = "name")]- Override column/table mapping (optional)