#[derive(Model)]
{
// Attributes available to this derive:
#[schema]
}
Expand description
Derives the Model
trait.
§Attributes on structs
-
#[schema(model_name = "name")]
: The default model name is obtained by converting the struct name to snake-case. You can override it by specifying themodel_name
attribute. -
#[schema(item_name = "name")]
: Theitem_name
attribute specifies the corresponding field for a single model data item. Default value:entry
. -
#[schema(item_name_plural = "name")]
: Theitem_name_plural
attribute specifies the corresponding field for model data items. Default value:entries
.
§Attributes on struct fields
-
#[schema(ignore)]
: Theignore
annotation is used to skip a particular field such that it disables the derived setter. -
#[schema(constructor = "path")]
: Theconstructor
attribute is used to create a new instance of the column type inModel::new()
. The function must be callable asfn() -> T
. -
#[schema(composable)]
: Thecomposable
annotation indicates that the column value relates to a particular model. It is only valid for the data typeM
,Option<M>
orVec<M>
, whereM
is a model. -
#[schema(read_only)]
: Theread_only
annotation indicates that the column is read-only and can not be modified after creation. It also can not been seen in the model definition. -
#[schema(generated)]
: Thegenerated
annotation indicates that the column value is generated by the backend and do not need any frontend input. The column will not been seen in the model definition. -
#[schema(reserved)]
: Thegenerated
annotation is used to mark a special column. It will not been seen in the model definition. Built-in reserved fields:created_at
|updated_at
|deleted_at
|is_deleted
|is_locked
|is_archived
|version
|edition
. -
#[schema(auto_initialized)]
: Theauto_initialized
annotation indicates that the column has an automatically initialized value. Different to thegenerated
column, anauto_initialized
value can be modified after creation. The column will not been seen in the model definition. -
#[schema(inherent)]
: Theinherent
annotation indicates that the column value is parsed by an associated function in the model’s inherent implementation.