pub struct HasMany {
pub target: ModelId,
pub expr_ty: Type,
pub singular: Name,
pub kind: HasKind,
}Expand description
The inverse side of a one-to-many relationship.
A HasMany field on model A means “A has many Bs”. A direct HasMany
pairs with a BelongsTo field on model B that holds the foreign key; a
multi-step (via) HasMany reaches B by following a path of existing
relations. Which one it is is recorded in kind.
§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).
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 HasMany
impl RefUnwindSafe for HasMany
impl Send for HasMany
impl Sync for HasMany
impl Unpin for HasMany
impl UnsafeUnpin 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