pub enum RelationKind {
HasOne,
HasMany,
BelongsTo,
ManyToMany,
}Expand description
关联关系类型
决定 JOIN 策略和数据加载方式:
HasOne/BelongsTo→ INNER JOIN(一条关联记录)HasMany/ManyToMany→ LEFT JOIN(多条关联记录,双查询策略避免行膨胀)
Variants§
HasOne
一对一:当前实体拥有一个关联实体(如 User → Profile)
HasMany
一对多:当前实体拥有多个关联实体(如 User → Orders)
BelongsTo
多对一:当前实体属于一个父实体(如 Order → User)
ManyToMany
多对多:通过中间表关联(如 User ↔ Role,通过 user_roles)
Implementations§
Source§impl RelationKind
impl RelationKind
Sourcepub fn default_join_type(self) -> JoinKind
pub fn default_join_type(self) -> JoinKind
返回该关系类型默认的 JOIN 类型
HasOne/BelongsTo→JoinKind::Inner(关联记录存在性要求)HasMany/ManyToMany→JoinKind::Left(允许零关联记录)
Trait Implementations§
Source§impl Clone for RelationKind
impl Clone for RelationKind
Source§fn clone(&self) -> RelationKind
fn clone(&self) -> RelationKind
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for RelationKind
Source§impl Debug for RelationKind
impl Debug for RelationKind
impl Eq for RelationKind
Source§impl Hash for RelationKind
impl Hash for RelationKind
Source§impl PartialEq for RelationKind
impl PartialEq for RelationKind
impl StructuralPartialEq for RelationKind
Auto Trait Implementations§
impl Freeze for RelationKind
impl RefUnwindSafe for RelationKind
impl Send for RelationKind
impl Sync for RelationKind
impl Unpin for RelationKind
impl UnsafeUnpin for RelationKind
impl UnwindSafe for RelationKind
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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