pub struct Relationship {
pub name: String,
pub target_type: String,
pub cardinality: Cardinality,
pub foreign_key: String,
pub referenced_key: String,
}Expand description
A relationship between two schema types for REST resource embedding.
Fields§
§name: StringRelationship name (used in ?select=posts embedding syntax).
target_type: StringTarget GraphQL type name (e.g., “Post”).
cardinality: CardinalityCardinality of the relationship.
foreign_key: StringForeign key column on the child table (e.g., fk_author).
referenced_key: StringReferenced key column on the parent table (e.g., id).
Implementations§
Source§impl Relationship
impl Relationship
Sourcepub const fn parent_join_column(&self) -> &String
pub const fn parent_join_column(&self) -> &String
The column an embed of this relationship reads off the declaring type’s row.
OneToMany hangs the foreign key on the child, so the declaring side is its
referenced_key — conventionally id, which a client selects anyway, which is
why #1230 hid here for so long. ManyToOne/OneToOne hold the key themselves,
so the declaring side is the foreign_key — the one column a client asking for
author has no reason to select.
Stated here rather than in the REST executor because the compile-time and load-time checks that a join key names a declared field (#1266) have to ask the same question the executor asks; a check with its own copy of this table would accept exactly the schemas the executor cannot follow.
Sourcepub const fn target_join_column(&self) -> &String
pub const fn target_join_column(&self) -> &String
The column the join predicate filters on the target row — the mirror of
parent_join_column, stated once so the two can
never drift apart.
Trait Implementations§
Source§impl Clone for Relationship
impl Clone for Relationship
Source§impl Debug for Relationship
impl Debug for Relationship
Source§impl<'de> Deserialize<'de> for Relationship
impl<'de> Deserialize<'de> for Relationship
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>,
impl Eq for Relationship
Source§impl PartialEq for Relationship
impl PartialEq for Relationship
Source§impl Serialize for Relationship
impl Serialize for Relationship
impl StructuralPartialEq for Relationship
Auto Trait Implementations§
impl Freeze for Relationship
impl RefUnwindSafe for Relationship
impl Send for Relationship
impl Sync for Relationship
impl Unpin for Relationship
impl UnsafeUnpin for Relationship
impl UnwindSafe for Relationship
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
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>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.