pub struct RelationshipInfo {Show 14 fields
pub name: &'static str,
pub related_table: &'static str,
pub kind: RelationshipKind,
pub local_key: Option<&'static str>,
pub remote_key: Option<&'static str>,
pub link_table: Option<LinkTableInfo>,
pub back_populates: Option<&'static str>,
pub lazy: bool,
pub cascade_delete: bool,
pub passive_deletes: PassiveDeletes,
pub order_by: Option<&'static str>,
pub lazy_strategy: Option<LazyLoadStrategy>,
pub cascade: Option<&'static str>,
pub uselist: Option<bool>,
}Expand description
Metadata about a relationship between models.
Fields§
§name: &'static strName of the relationship field.
The related model’s table name.
kind: RelationshipKindKind of relationship.
local_key: Option<&'static str>Local foreign key column (for ManyToOne).
e.g., "team_id" on Hero.
remote_key: Option<&'static str>Remote foreign key column (for OneToMany).
e.g., "team_id" on Hero when accessed from Team.
link_table: Option<LinkTableInfo>Link table for ManyToMany relationships.
back_populates: Option<&'static str>The field on the related model that points back.
lazy: boolWhether to use lazy loading (simple flag).
cascade_delete: boolCascade delete behavior.
passive_deletes: PassiveDeletesPassive delete behavior - whether ORM emits DELETE or relies on DB cascade.
order_by: Option<&'static str>Default ordering for related items (e.g., “name”, “created_at DESC”).
lazy_strategy: Option<LazyLoadStrategy>Loading strategy for this relationship.
cascade: Option<&'static str>Full cascade options string (e.g., “all, delete-orphan”).
uselist: Option<bool>Force list or single (override field type inference).
Some(true): Always return a listSome(false): Always return a single itemNone: Infer from field type
Implementations§
Source§impl RelationshipInfo
impl RelationshipInfo
Sourcepub const fn new(
name: &'static str,
related_table: &'static str,
kind: RelationshipKind,
) -> Self
pub const fn new( name: &'static str, related_table: &'static str, kind: RelationshipKind, ) -> Self
Create a new relationship with required fields.
Sourcepub const fn local_key(self, key: &'static str) -> Self
pub const fn local_key(self, key: &'static str) -> Self
Set the local foreign key column (ManyToOne).
Sourcepub const fn remote_key(self, key: &'static str) -> Self
pub const fn remote_key(self, key: &'static str) -> Self
Set the remote foreign key column (OneToMany).
Sourcepub const fn link_table(self, info: LinkTableInfo) -> Self
pub const fn link_table(self, info: LinkTableInfo) -> Self
Set the link table metadata (ManyToMany).
Sourcepub const fn back_populates(self, field: &'static str) -> Self
pub const fn back_populates(self, field: &'static str) -> Self
Set the back-populates field name (bidirectional relationships).
Sourcepub const fn cascade_delete(self, value: bool) -> Self
pub const fn cascade_delete(self, value: bool) -> Self
Enable/disable cascade delete behavior.
Sourcepub const fn passive_deletes(self, value: PassiveDeletes) -> Self
pub const fn passive_deletes(self, value: PassiveDeletes) -> Self
Set passive delete behavior.
PassiveDeletes::Active(default): ORM emits DELETE for related objectsPassiveDeletes::Passive: Relies on DB ON DELETE CASCADEPassiveDeletes::All: Passive + disables orphan tracking
Sourcepub const fn order_by(self, ordering: &'static str) -> Self
pub const fn order_by(self, ordering: &'static str) -> Self
Set default ordering for related items.
Sourcepub const fn order_by_opt(self, ordering: Option<&'static str>) -> Self
pub const fn order_by_opt(self, ordering: Option<&'static str>) -> Self
Set default ordering from optional.
Sourcepub const fn lazy_strategy(self, strategy: LazyLoadStrategy) -> Self
pub const fn lazy_strategy(self, strategy: LazyLoadStrategy) -> Self
Set the lazy loading strategy.
Sourcepub const fn lazy_strategy_opt(self, strategy: Option<LazyLoadStrategy>) -> Self
pub const fn lazy_strategy_opt(self, strategy: Option<LazyLoadStrategy>) -> Self
Set the lazy loading strategy from optional.
Sourcepub const fn cascade_opt(self, opts: Option<&'static str>) -> Self
pub const fn cascade_opt(self, opts: Option<&'static str>) -> Self
Set cascade options from optional.
Sourcepub const fn uselist_opt(self, value: Option<bool>) -> Self
pub const fn uselist_opt(self, value: Option<bool>) -> Self
Set uselist from optional.
Sourcepub const fn is_passive_deletes(&self) -> bool
pub const fn is_passive_deletes(&self) -> bool
Check if passive deletes are enabled (Passive or All).
Sourcepub const fn is_passive_deletes_all(&self) -> bool
pub const fn is_passive_deletes_all(&self) -> bool
Check if orphan tracking is disabled (passive_deletes=‘all’).
Trait Implementations§
Source§impl Clone for RelationshipInfo
impl Clone for RelationshipInfo
Source§fn clone(&self) -> RelationshipInfo
fn clone(&self) -> RelationshipInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more