#[non_exhaustive]pub struct RelationConfig {
pub name: String,
pub title: Text,
pub label: Text,
pub entity: String,
pub foreign_key: Option<String>,
pub pivot: Option<PivotConfig>,
pub list: ListConfig,
pub form: FormConfig,
pub permission: Option<String>,
}Expand description
One relation a resource declares, listed and edited on the parent’s edit
page: rows of entity whose foreign_key holds the parent’s id (has-many),
or rows of entity a pivot table joins to the parent (many-to-many).
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringThe relation’s name: the key in a descriptor, the path segment under
the parent (/products/7/variants). Not new, edit, delete,
import, export or columns, which the parent’s own routes use.
title: TextThe section heading, plural (Variants). Defaults to the name,
humanized.
label: TextOne related record, singular (Variant), for the New or Attach button
and the child form’s title.
entity: StringThe related table.
foreign_key: Option<String>Has-many: the column on the related table holding the parent’s id.
pivot: Option<PivotConfig>Many-to-many: the table joining the parent to the related table.
list: ListConfigThe section’s list over the related table.
form: FormConfigHas-many: the related record’s form; the foreign key is written by the framework, and a field of that name here is kept hidden. Many-to-many: the fields kept on the pivot row, asked for on Attach and editable from the section; none means a membership carries nothing of its own.
permission: Option<String>A permission the operator must hold for the section and its pages,
besides the parent’s. None asks for the parent’s alone.
Implementations§
Source§impl RelationConfig
impl RelationConfig
Sourcepub fn has_many(
name: impl Into<String>,
label: impl Into<Text>,
entity: impl Into<String>,
foreign_key: impl Into<String>,
list: ListConfig,
form: FormConfig,
) -> Self
pub fn has_many( name: impl Into<String>, label: impl Into<Text>, entity: impl Into<String>, foreign_key: impl Into<String>, list: ListConfig, form: FormConfig, ) -> Self
A has-many relation: rows of entity whose foreign_key names the
parent, listed by list and edited through form.
Sourcepub fn belongs_to_many(
name: impl Into<String>,
label: impl Into<Text>,
entity: impl Into<String>,
pivot: PivotConfig,
list: ListConfig,
) -> Self
pub fn belongs_to_many( name: impl Into<String>, label: impl Into<Text>, entity: impl Into<String>, pivot: PivotConfig, list: ListConfig, ) -> Self
A many-to-many relation: rows of entity that pivot joins to the
parent, listed by list. Fields kept on the pivot row go on form.
Sourcepub fn form(self, form: FormConfig) -> Self
pub fn form(self, form: FormConfig) -> Self
The fields kept on a many-to-many relation’s pivot row.
Sourcepub fn permission(self, code: impl Into<String>) -> Self
pub fn permission(self, code: impl Into<String>) -> Self
A permission the operator must also hold.
Trait Implementations§
Source§impl Clone for RelationConfig
impl Clone for RelationConfig
Source§impl Debug for RelationConfig
impl Debug for RelationConfig
Source§impl Default for RelationConfig
impl Default for RelationConfig
Source§impl<'de> Deserialize<'de> for RelationConfigwhere
RelationConfig: Default,
impl<'de> Deserialize<'de> for RelationConfigwhere
RelationConfig: Default,
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>,
Auto Trait Implementations§
impl !RefUnwindSafe for RelationConfig
impl !UnwindSafe for RelationConfig
impl Freeze for RelationConfig
impl Send for RelationConfig
impl Sync for RelationConfig
impl Unpin for RelationConfig
impl UnsafeUnpin for RelationConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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