Skip to main content

Model

Trait Model 

Source
pub trait Model:
    Sized
    + Send
    + Sync {
    const MODEL_NAME: &'static str;
    const TABLE_NAME: &'static str;
    const PRIMARY_KEY: &'static [&'static str];
    const COLUMNS: &'static [&'static str];
    const GENERATED_FIELDS: &'static [(&'static str, &'static str, bool)] = _;
    const AGGREGATE_FIELDS: &'static [(&'static str, &'static str, &'static str, Option<&'static str>)] = _;
}
Expand description

A model that can be queried.

Required Associated Constants§

Source

const MODEL_NAME: &'static str

The name of the model (used for table name).

Source

const TABLE_NAME: &'static str

The name of the database table.

Source

const PRIMARY_KEY: &'static [&'static str]

The primary key column name(s).

Source

const COLUMNS: &'static [&'static str]

All column names for this model.

Provided Associated Constants§

Source

const GENERATED_FIELDS: &'static [(&'static str, &'static str, bool)] = _

Metadata for fields annotated with #[prax(generated = "expr")].

Each entry is (field_name, expression, stored) where stored is true for a physically-stored generated column and false for a virtual (computed-on-read) column.

Models without any generated fields default to an empty slice.

Source

const AGGREGATE_FIELDS: &'static [(&'static str, &'static str, &'static str, Option<&'static str>)] = _

Metadata for fields annotated with aggregate directives (#[prax(count(rel))], #[prax(sum(rel.field))], etc.).

Each entry is (field_name, kind_str, relation, field) where kind_str is one of "count", "sum", "avg", "min", "max", relation is the relation name, and field is the target field (always None for count).

Models without any aggregate fields default to an empty slice.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§