pub struct HasOne {
pub target: ModelId,
pub expr_ty: Type,
pub kind: HasKind,
}Expand description
The inverse side of a one-to-one relationship.
A HasOne field on model A means “A has exactly one B”. A direct HasOne
pairs with a BelongsTo field on model B that holds the foreign key; a
multi-step (via) HasOne reaches B by following a path of existing
relations. Which one it is is recorded in kind.
§Examples
ⓘ
// Given a `User` model that has one `Profile`:
let has_one: &HasOne = user_field.ty.as_has_one_unwrap();
let profile_model = has_one.target(&schema);
let inverse = has_one.pair(&schema); // the BelongsTo on ProfileFields§
§target: ModelIdThe ModelId of the associated (target) model.
expr_ty: TypeThe expression type this field evaluates to from the application’s perspective.
kind: HasKindHow this relation reaches its target — a paired BelongsTo
(HasKind::Direct) or a Via path
(HasKind::Via).
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HasOne
impl RefUnwindSafe for HasOne
impl Send for HasOne
impl Sync for HasOne
impl Unpin for HasOne
impl UnsafeUnpin for HasOne
impl UnwindSafe for HasOne
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