Trait diesel::associations::BelongsTo
source · pub trait BelongsTo<Parent> {
type ForeignKey: Hash + Eq;
type ForeignKeyColumn: Column;
// Required methods
fn foreign_key(&self) -> Option<&Self::ForeignKey>;
fn foreign_key_column() -> Self::ForeignKeyColumn;
}
Expand description
Indicates that a type belongs to Parent
Specifically, this means that this struct has fields
which correspond to the primary key of Parent
.
This implies that a foreign key relationship exists on the tables.
This trait is not capable of supporting composite foreign keys
Required Associated Types§
sourcetype ForeignKey: Hash + Eq
type ForeignKey: Hash + Eq
The foreign key of this struct
sourcetype ForeignKeyColumn: Column
type ForeignKeyColumn: Column
The database column representing the foreign key of the table this struct represents
Required Methods§
sourcefn foreign_key(&self) -> Option<&Self::ForeignKey>
fn foreign_key(&self) -> Option<&Self::ForeignKey>
Returns the foreign key for self
sourcefn foreign_key_column() -> Self::ForeignKeyColumn
fn foreign_key_column() -> Self::ForeignKeyColumn
Returns the foreign key column of this struct’s table