Skip to main content

RelationBuilder

Struct RelationBuilder 

Source
pub struct RelationBuilder<E, R>
where E: EntityTrait, R: EntityTrait,
{ /* private fields */ }
Expand description

Fluent builder for a RelationDef. Construct one via EntityTrait::belongs_to / has_one / has_many.

Implementations§

Source§

impl<E, R> RelationBuilder<E, R>
where E: EntityTrait, R: EntityTrait,

Source

pub fn from<T>(self, identifier: T) -> Self
where T: IdentityOf<E>,

Column(s) on the FK-owning side. Accepts a column or a tuple of columns for composite keys.

Source

pub fn to<T>(self, identifier: T) -> Self
where T: IdentityOf<R>,

Column(s) on the referenced side (usually the related entity’s primary key). Accepts a column or a tuple of columns for composite keys.

Source

pub fn skip_fk(self) -> Self

Don’t emit a FOREIGN KEY constraint when this relation is used to generate schema DDL.

Source

pub fn on_delete(self, action: ForeignKeyAction) -> Self

Set the ON DELETE action for the foreign key (e.g. Cascade, SetNull).

Source

pub fn on_update(self, action: ForeignKeyAction) -> Self

Set the ON UPDATE action for the foreign key.

Source

pub fn on_condition<F>(self, f: F) -> Self
where F: Fn(DynIden, DynIden) -> Condition + 'static,

Add an extra predicate to the join’s ON clause. The closure receives the left-hand-side and right-hand-side table idens.

Source

pub fn fk_name(self, fk_name: &str) -> Self

Override the name of the FOREIGN KEY constraint emitted in DDL.

Source

pub fn condition_type(self, condition_type: ConditionType) -> Self

Combine the column equality and on_condition with AND (ConditionType::All, default) or OR (ConditionType::Any).

Trait Implementations§

Source§

impl<E, R> Debug for RelationBuilder<E, R>

Source§

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

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

impl<E, R> From<RelationBuilder<E, R>> for RelationDef
where E: EntityTrait, R: EntityTrait,

Source§

fn from(b: RelationBuilder<E, R>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<E, R> !RefUnwindSafe for RelationBuilder<E, R>

§

impl<E, R> !Send for RelationBuilder<E, R>

§

impl<E, R> !Sync for RelationBuilder<E, R>

§

impl<E, R> !UnwindSafe for RelationBuilder<E, R>

§

impl<E, R> Freeze for RelationBuilder<E, R>

§

impl<E, R> Unpin for RelationBuilder<E, R>
where E: Unpin, R: Unpin,

§

impl<E, R> UnsafeUnpin for RelationBuilder<E, R>

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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: 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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