pub trait Model: ModelHooks {
type Pk: PrimaryKey;
// Required methods
fn table_name() -> &'static str;
fn schema() -> TableSchema;
}Expand description
Core trait implemented by #[derive(Model)].
Every model must be able to describe its own schema.
ModelHooks is a supertrait: the derive emits an empty impl unless #[model(hooks)] is set.
Required Associated Types§
Sourcetype Pk: PrimaryKey
type Pk: PrimaryKey
The Rust type of the primary key value (Uuid, i32, i64).
ForeignKey<Self> and ManyToMany<Self> columns follow it.
Required Methods§
Sourcefn table_name() -> &'static str
fn table_name() -> &'static str
The table name in the database.
Sourcefn schema() -> TableSchema
fn schema() -> TableSchema
The full schema description for this model.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".