pub struct BelongsTo {
pub target: ModelId,
pub expr_ty: Type,
pub pair: Option<FieldId>,
pub foreign_key: ForeignKey,
}Expand description
The owning side of a relationship. Stores the foreign key that references another model’s primary key.
A BelongsTo field does not store data in its own column; instead, its
ForeignKey contains one or more primitive fields on the same model
whose values match the target model’s primary key.
§Examples
ⓘ
// Given a `Comment` model that belongs to a `Post`:
let belongs_to: &BelongsTo = comment_field.ty.as_belongs_to_unwrap();
let post_model = belongs_to.target(&schema);Fields§
§target: ModelIdThe ModelId of the referenced (target) model.
expr_ty: TypeThe expression type this field evaluates to from the application’s perspective.
pair: Option<FieldId>§foreign_key: ForeignKeyThe foreign key mapping source fields to the target’s primary key fields.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BelongsTo
impl RefUnwindSafe for BelongsTo
impl Send for BelongsTo
impl Sync for BelongsTo
impl Unpin for BelongsTo
impl UnwindSafe for BelongsTo
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