#[derive(Entity)]
{
// Attributes available to this derive:
#[microrm_internal]
#[microrm_foreign]
#[microrm_unique]
}
Expand description
Turns a serializable/deserializable struct into a microrm entity model.
There are two important visible effects:
- Provides an implementation of
microrm::entity::Entity
- Defines a
Columns enum
Note that names are converted from CamelCase to snake_case and vice versa
where applicable, so a struct named TestModel
is given a table name test_model
and a struct field named field_name
is given a variant name of FieldName
.
The #[microrm...]
attributes can be used to control the derivation somewhat.
The following are understood for the Entity struct:
#[microrm_internal]
: this is internal to the microrm crate (of extremely limited usefulness outside the microrm library)
The following are understood on individual fields:
#[microrm_foreign]
: this is a foreign key (and the field must be of a type implementingEntityID
)#[microrm_unique]
: this field is part of a unique index constraint on this entity’s table