pub struct HasMany {
pub target: ModelId,
pub expr_ty: Type,
pub singular: Name,
pub pair: FieldId,
}Expand description
The inverse side of a one-to-many relationship.
A HasMany field on model A means “A has many Bs”. The actual foreign key
lives on model B as a BelongsTo field pointing back at A. The two
sides are linked via the pair field.
§Examples
ⓘ
// Given a `User` model that has many `Post`s:
let has_many: &HasMany = user_field.ty.as_has_many_unwrap();
let post_model = has_many.target(&schema);
let inverse = has_many.pair(&schema); // the BelongsTo on PostFields§
§target: ModelIdThe ModelId of the associated (target) model.
expr_ty: TypeThe expression type this field evaluates to from the application’s perspective.
singular: NameThe singular name for one associated item (used in generated method names).
pair: FieldIdThe BelongsTo field on the target model that pairs with this
relation.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HasMany
impl RefUnwindSafe for HasMany
impl Send for HasMany
impl Sync for HasMany
impl Unpin for HasMany
impl UnwindSafe for HasMany
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