pub struct ManyToManyDefinition {
pub entity_a: String,
pub entity_b: String,
pub junction_table: Option<String>,
pub entity_a_field: String,
pub entity_b_field: String,
pub on_delete_a: CascadeAction,
pub on_delete_b: CascadeAction,
}Expand description
Many-to-many relationship definition
Represents a many-to-many relationship between two entities using a junction table. For example, Users and Roles with a user_roles junction table.
Fields§
§entity_a: StringFirst entity name
entity_b: StringSecond entity name
junction_table: Option<String>Junction table name (auto-generated if not provided) Format: “{entity_a}{entity_b}” or “{entity_b}{entity_a}” (alphabetically sorted)
entity_a_field: StringForeign key field name in junction table pointing to entity_a
entity_b_field: StringForeign key field name in junction table pointing to entity_b
on_delete_a: CascadeActionCascade action on delete for entity_a
on_delete_b: CascadeActionCascade action on delete for entity_b
Implementations§
Source§impl ManyToManyDefinition
impl ManyToManyDefinition
Sourcepub fn new(entity_a: String, entity_b: String) -> Self
pub fn new(entity_a: String, entity_b: String) -> Self
Create a new many-to-many relationship definition
Sourcepub fn with_junction_table(self, table_name: String) -> Self
pub fn with_junction_table(self, table_name: String) -> Self
Set the junction table name
Sourcepub fn with_fields(self, entity_a_field: String, entity_b_field: String) -> Self
pub fn with_fields(self, entity_a_field: String, entity_b_field: String) -> Self
Set the foreign key field names
Sourcepub fn with_cascade_actions(
self,
on_delete_a: CascadeAction,
on_delete_b: CascadeAction,
) -> Self
pub fn with_cascade_actions( self, on_delete_a: CascadeAction, on_delete_b: CascadeAction, ) -> Self
Set cascade actions
Trait Implementations§
Source§impl Clone for ManyToManyDefinition
impl Clone for ManyToManyDefinition
Source§fn clone(&self) -> ManyToManyDefinition
fn clone(&self) -> ManyToManyDefinition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ManyToManyDefinition
impl Debug for ManyToManyDefinition
Source§impl<'de> Deserialize<'de> for ManyToManyDefinition
impl<'de> Deserialize<'de> for ManyToManyDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ManyToManyDefinition
impl RefUnwindSafe for ManyToManyDefinition
impl Send for ManyToManyDefinition
impl Sync for ManyToManyDefinition
impl Unpin for ManyToManyDefinition
impl UnsafeUnpin for ManyToManyDefinition
impl UnwindSafe for ManyToManyDefinition
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
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