Skip to main content

Model

Trait Model 

Source
pub trait Model:
    DriverRows
    + Send
    + Unpin
    + Sized {
    const TABLE: &'static str;
    const PRIMARY_KEY: &'static str = "id";
    const FILLABLE: &'static [&'static str] = _;

    // Provided method
    fn query() -> Query<Self> { ... }
}
Expand description

A table and the Rust type that its rows map to. Derive it with #[derive(OrbitModel)], or write it by hand.

A model decodes from the row type of every database that the build enables, so DriverRows holds for it. With only one database enabled, that is the one FromRow for that database.

Required Associated Constants§

Source

const TABLE: &'static str

The table name.

Provided Associated Constants§

Source

const PRIMARY_KEY: &'static str = "id"

The primary key, used by find. first has no default order, as in Laravel.

Source

const FILLABLE: &'static [&'static str] = _

The columns that insert and update may write. Empty by default, as in Laravel’s $fillable.

Provided Methods§

Source

fn query() -> Query<Self>

Starts a query on the table.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§