pub struct ForeignKey<M: Model>(pub <M as Model>::Pk, _);Expand description
A foreign key reference: stores the primary key value of the related model.
The value type follows the target’s primary key (Model::Pk): Uuid for FieldUuid,
i32 for FieldAutoInt, i64 for FieldAutoBigInt. The column type in the schema
and migrations follows it too.
§Example
ⓘ
#[derive(Model)]
struct Article {
id: FieldUuid,
author_id: ForeignKey<User>,
}Tuple Fields§
§0: <M as Model>::PkImplementations§
Trait Implementations§
Source§impl<M: Model> Clone for ForeignKey<M>
impl<M: Model> Clone for ForeignKey<M>
impl<M: Model> Copy for ForeignKey<M>
Source§impl<M: Model> Debug for ForeignKey<M>
impl<M: Model> Debug for ForeignKey<M>
Source§impl<'de, M: Model> Deserialize<'de> for ForeignKey<M>
impl<'de, M: Model> Deserialize<'de> for ForeignKey<M>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<M: Model> Eq for ForeignKey<M>
Source§impl<M: Model<Pk = Uuid>> FilterValue<ForeignKey<M>> for Uuid
impl<M: Model<Pk = Uuid>> FilterValue<ForeignKey<M>> for Uuid
fn into_sql_value(self) -> SqlValue
Source§impl<M: Model<Pk = i32>> FilterValue<ForeignKey<M>> for i32
impl<M: Model<Pk = i32>> FilterValue<ForeignKey<M>> for i32
fn into_sql_value(self) -> SqlValue
Source§impl<M: Model<Pk = i64>> FilterValue<ForeignKey<M>> for i64
impl<M: Model<Pk = i64>> FilterValue<ForeignKey<M>> for i64
fn into_sql_value(self) -> SqlValue
Source§impl<M: Model<Pk = Uuid>> FilterValue<ForeignKey<M>> for FieldUuid
impl<M: Model<Pk = Uuid>> FilterValue<ForeignKey<M>> for FieldUuid
fn into_sql_value(self) -> SqlValue
Source§impl<M: Model> Hash for ForeignKey<M>
impl<M: Model> Hash for ForeignKey<M>
Source§impl<M: Model> PartialEq for ForeignKey<M>
impl<M: Model> PartialEq for ForeignKey<M>
Source§impl<M: Model> Serialize for ForeignKey<M>
impl<M: Model> Serialize for ForeignKey<M>
Source§impl<M: Model> ToSqlValue for ForeignKey<M>
impl<M: Model> ToSqlValue for ForeignKey<M>
fn to_sql_value(&self) -> SqlValue
Auto Trait Implementations§
impl<M> Forget for ForeignKey<M>
impl<M> Freeze for ForeignKey<M>
impl<M> RefUnwindSafe for ForeignKey<M>
impl<M> Send for ForeignKey<M>
impl<M> Sync for ForeignKey<M>
impl<M> Unpin for ForeignKey<M>
impl<M> UnsafeUnpin for ForeignKey<M>
impl<M> UnwindSafe for ForeignKey<M>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more