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,
impl<E, R> RelationBuilder<E, R>where
E: EntityTrait,
R: EntityTrait,
Sourcepub fn from<T>(self, identifier: T) -> Selfwhere
T: IdentityOf<E>,
pub fn from<T>(self, identifier: T) -> Selfwhere
T: IdentityOf<E>,
Column(s) on the FK-owning side. Accepts a column or a tuple of columns for composite keys.
Sourcepub fn to<T>(self, identifier: T) -> Selfwhere
T: IdentityOf<R>,
pub fn to<T>(self, identifier: T) -> Selfwhere
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.
Sourcepub fn skip_fk(self) -> Self
pub fn skip_fk(self) -> Self
Don’t emit a FOREIGN KEY constraint when this relation is used to
generate schema DDL.
Sourcepub fn on_delete(self, action: ForeignKeyAction) -> Self
pub fn on_delete(self, action: ForeignKeyAction) -> Self
Set the ON DELETE action for the foreign key (e.g. Cascade,
SetNull).
Sourcepub fn on_update(self, action: ForeignKeyAction) -> Self
pub fn on_update(self, action: ForeignKeyAction) -> Self
Set the ON UPDATE action for the foreign key.
Sourcepub fn on_condition<F>(self, f: F) -> Self
pub fn on_condition<F>(self, f: F) -> Self
Add an extra predicate to the join’s ON clause. The closure receives
the left-hand-side and right-hand-side table idens.
Sourcepub fn fk_name(self, fk_name: &str) -> Self
pub fn fk_name(self, fk_name: &str) -> Self
Override the name of the FOREIGN KEY constraint emitted in DDL.
Sourcepub fn condition_type(self, condition_type: ConditionType) -> Self
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>
impl<E, R> Debug for RelationBuilder<E, R>
Source§impl<E, R> From<RelationBuilder<E, R>> for RelationDefwhere
E: EntityTrait,
R: EntityTrait,
impl<E, R> From<RelationBuilder<E, R>> for RelationDefwhere
E: EntityTrait,
R: EntityTrait,
Source§fn from(b: RelationBuilder<E, R>) -> Self
fn from(b: RelationBuilder<E, R>) -> Self
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>
impl<E, R> UnsafeUnpin for RelationBuilder<E, R>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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>
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>
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