Skip to main content

RelationshipInfo

Struct RelationshipInfo 

Source
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 str

Name of the relationship field.

§related_table: &'static str

The related model’s table name.

§kind: RelationshipKind

Kind 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: bool

Whether to use lazy loading (simple flag).

§cascade_delete: bool

Cascade delete behavior.

§passive_deletes: PassiveDeletes

Passive 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 list
  • Some(false): Always return a single item
  • None: Infer from field type

Implementations§

Source§

impl RelationshipInfo

Source

pub const fn new( name: &'static str, related_table: &'static str, kind: RelationshipKind, ) -> Self

Create a new relationship with required fields.

Source

pub const fn local_key(self, key: &'static str) -> Self

Set the local foreign key column (ManyToOne).

Source

pub const fn remote_key(self, key: &'static str) -> Self

Set the remote foreign key column (OneToMany).

Set the link table metadata (ManyToMany).

Source

pub const fn back_populates(self, field: &'static str) -> Self

Set the back-populates field name (bidirectional relationships).

Source

pub const fn lazy(self, value: bool) -> Self

Enable/disable lazy loading.

Source

pub const fn cascade_delete(self, value: bool) -> Self

Enable/disable cascade delete behavior.

Source

pub const fn passive_deletes(self, value: PassiveDeletes) -> Self

Set passive delete behavior.

  • PassiveDeletes::Active (default): ORM emits DELETE for related objects
  • PassiveDeletes::Passive: Relies on DB ON DELETE CASCADE
  • PassiveDeletes::All: Passive + disables orphan tracking
Source

pub const fn order_by(self, ordering: &'static str) -> Self

Set default ordering for related items.

Source

pub const fn order_by_opt(self, ordering: Option<&'static str>) -> Self

Set default ordering from optional.

Source

pub const fn lazy_strategy(self, strategy: LazyLoadStrategy) -> Self

Set the lazy loading strategy.

Source

pub const fn lazy_strategy_opt(self, strategy: Option<LazyLoadStrategy>) -> Self

Set the lazy loading strategy from optional.

Source

pub const fn cascade(self, opts: &'static str) -> Self

Set full cascade options string.

Source

pub const fn cascade_opt(self, opts: Option<&'static str>) -> Self

Set cascade options from optional.

Source

pub const fn uselist(self, value: bool) -> Self

Force list or single.

Source

pub const fn uselist_opt(self, value: Option<bool>) -> Self

Set uselist from optional.

Source

pub const fn is_passive_deletes(&self) -> bool

Check if passive deletes are enabled (Passive or All).

Source

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

Source§

fn clone(&self) -> RelationshipInfo

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RelationshipInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RelationshipInfo

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for RelationshipInfo

Source§

fn eq(&self, other: &RelationshipInfo) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for RelationshipInfo

Source§

impl Eq for RelationshipInfo

Source§

impl StructuralPartialEq for RelationshipInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more