pub struct HasOne {
pub target: ModelId,
pub expr_ty: Type,
pub pair: FieldId,
}Expand description
The inverse side of a one-to-one relationship.
A HasOne field on model A means “A has exactly one B”. The actual foreign
key lives on model B as a BelongsTo field. The two sides are linked via
the pair field.
§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.
pair: FieldIdThe BelongsTo field on the target model that pairs with this
relation.
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 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