Trait atmosphere::Table

source ·
pub trait Table: Sized + Send + for<'r> FromRow<'r, <Postgres as Database>::Row> + 'static {
    type PrimaryKey: Sync + Sized + 'static + for<'q> Encode<'q, Postgres> + Type<Postgres> + Send;

    const SCHEMA: &'static str;
    const TABLE: &'static str;
    const PRIMARY_KEY: PrimaryKey<Self>;
    const FOREIGN_KEYS: &'static [ForeignKey<Self>];
    const DATA_COLUMNS: &'static [DataColumn<Self>];
    const TIMESTAMP_COLUMNS: &'static [TimestampColumn<Self>];

    // Required method
    fn pk(&self) -> &Self::PrimaryKey;
}
Expand description

SQL Table Definition

Represents the definition of a SQL table within the framework, encompassing primary keys, foreign keys, data columns, and timestamp columns. This trait should be implemented by structs that represent database tables, providing metadata and utility functions for table manipulation and query building.

Required Associated Types§

source

type PrimaryKey: Sync + Sized + 'static + for<'q> Encode<'q, Postgres> + Type<Postgres> + Send

The type of the primary key for the table.

Required Associated Constants§

source

const SCHEMA: &'static str

The database schema in which the table resides.

source

const TABLE: &'static str

The name of the table.

source

const PRIMARY_KEY: PrimaryKey<Self>

The primary key column of the table.

source

const FOREIGN_KEYS: &'static [ForeignKey<Self>]

An array of foreign key columns.

source

const DATA_COLUMNS: &'static [DataColumn<Self>]

An array of data columns.

source

const TIMESTAMP_COLUMNS: &'static [TimestampColumn<Self>]

An array of timestamp columns.

Required Methods§

source

fn pk(&self) -> &Self::PrimaryKey

Returns a reference to the primary key of the table instance.

Object Safety§

This trait is not object safe.

Implementors§