pub trait Tablewhere
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§
Sourceconst PRIMARY_KEY: PrimaryKey<Self>
const PRIMARY_KEY: PrimaryKey<Self>
The primary key column of the table.
Sourceconst FOREIGN_KEYS: &'static [ForeignKey<Self>]
const FOREIGN_KEYS: &'static [ForeignKey<Self>]
An array of foreign key columns.
Sourceconst DATA_COLUMNS: &'static [DataColumn<Self>]
const DATA_COLUMNS: &'static [DataColumn<Self>]
An array of data columns.
Sourceconst TIMESTAMP_COLUMNS: &'static [TimestampColumn<Self>]
const TIMESTAMP_COLUMNS: &'static [TimestampColumn<Self>]
An array of timestamp columns.
Required Associated Types§
Sourcetype PrimaryKey: Sync + Sized + 'static
type PrimaryKey: Sync + Sized + 'static
The type of the primary key for the table.
Required Methods§
Sourcefn pk(&self) -> &Self::PrimaryKey
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.