Table

Trait Table 

Source
pub trait Table
where Self: Sized + Send + for<'r> FromRow<'r, <Driver as Database>::Row> + 'static, Self::PrimaryKey: for<'q> Encode<'q, Driver> + Type<Driver> + Send,
{ type PrimaryKey: Sync + Sized + 'static; 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 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 Associated Types§

Source

type PrimaryKey: Sync + Sized + 'static

The type of the primary key for the table.

Required Methods§

Source

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

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§