pub enum Relation {
BelongsTo(BelongsTo),
HasMany(HasMany),
HasOne(HasOne),
BelongsToMany(BelongsToMany),
MorphMany(MorphMany),
MorphTo(MorphTo),
}Expand description
模型间的关系描述
Variants§
BelongsTo(BelongsTo)
多对一关系(如 Order 属于 User)
HasMany(HasMany)
一对多关系(如 User 有多个 Order)
HasOne(HasOne)
一对一关系(如 User 有一个 Profile)
BelongsToMany(BelongsToMany)
多对多关系(通过中间表,如 User 与 Role)
MorphMany(MorphMany)
多态一对多(如 Comment 可关联 Post / Video / Image 等多种父模型) 子表通过 morph_type_column + morph_id_column 反向定位父模型
MorphTo(MorphTo)
多态反向:当前模型可被多种父模型拥有(当前模型持有 morph_type + morph_id 两列)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Relation
impl RefUnwindSafe for Relation
impl Send for Relation
impl Sync for Relation
impl Unpin for Relation
impl UnsafeUnpin for Relation
impl UnwindSafe for Relation
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more