[−][src]Struct juniper_eager_loading::HasManyThrough
A "has many through" association.
Imagine you have these models:
struct User { id: i32, } struct Company { id: i32, } struct Employments { id: i32, user_id: i32, company_id: i32, }
For this setup we say "user has many companies through employments". This means uses can work
at many companies and companies can have many employees, provided that we join with Employment
.
This requires that we use the JoinModel
type
on EagerLoadChildrenOfType
and is therefore a bit different from the other associations
since it involves a third type.
Example
You can find a complete example of HasManyThrough
here.
Attributes
Name | Description | Default | Example |
---|---|---|---|
model_field | The field on the contained type that holds the model | {name of contained type} in snakecase | model_field = company |
join_model | The model we have to join with | N/A | join_model = models::Employment |
child_primary_key_field_on_join_model | The field on the join model that holds the primary key of the child model (Company in the example above) | {name of model}_id | child_primary_key_field_on_join_model = company_identifier |
foreign_key_field | The field on the join model that holds the primary key of the parent model (User in the example above) | {name of model}_id | foreign_key_field = user_identifier |
child_primary_key_field | The field on the child model that holds its primary key | id | foreign_key_field = identifier |
graphql_field | The name of this field in your GraphQL schema | {name of field} | graphql_field = country |
predicate_method | Method used to filter child associations. This can be used if you only want to include a subset of the models. This method will be called to filter the join models. | N/A (attribute is optional) | predicate_method = a_predicate_method |
Additionally it also supports the attributes print
, skip
, and field_arguments
. See the root model
docs for more into on those.
Errors
try_unwrap
will never error. If the association wasn't loaded or wasn't found it will
return Ok(vec![])
.
Methods
impl<T> HasManyThrough<T>
[src]
pub fn try_unwrap(&self) -> Result<&Vec<T>, Error>
[src]
Borrow the loaded values. If no values have been loaded it will return an empty list. It will not return an error.
Trait Implementations
impl<T> Association<T> for HasManyThrough<T>
[src]
fn loaded_child(&mut self, child: T)
[src]
fn assert_loaded_otherwise_failed(&mut self)
[src]
impl<T: Clone> Clone for HasManyThrough<T>
[src]
fn clone(&self) -> HasManyThrough<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Debug> Debug for HasManyThrough<T>
[src]
impl<T> Default for HasManyThrough<T>
[src]
impl<T: Eq> Eq for HasManyThrough<T>
[src]
impl<T: Ord> Ord for HasManyThrough<T>
[src]
fn cmp(&self, other: &HasManyThrough<T>) -> Ordering
[src]
#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<HasManyThrough<T>> for HasManyThrough<T>
[src]
fn eq(&self, other: &HasManyThrough<T>) -> bool
[src]
fn ne(&self, other: &HasManyThrough<T>) -> bool
[src]
impl<T: PartialOrd> PartialOrd<HasManyThrough<T>> for HasManyThrough<T>
[src]
fn partial_cmp(&self, other: &HasManyThrough<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &HasManyThrough<T>) -> bool
[src]
fn le(&self, other: &HasManyThrough<T>) -> bool
[src]
fn gt(&self, other: &HasManyThrough<T>) -> bool
[src]
fn ge(&self, other: &HasManyThrough<T>) -> bool
[src]
impl<T> StructuralEq for HasManyThrough<T>
[src]
impl<T> StructuralPartialEq for HasManyThrough<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for HasManyThrough<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for HasManyThrough<T> where
T: Send,
T: Send,
impl<T> Sync for HasManyThrough<T> where
T: Sync,
T: Sync,
impl<T> Unpin for HasManyThrough<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for HasManyThrough<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,