pub struct HasMany<P, C> { /* private fields */ }Expand description
One parent, many children.
ⓘ
// A user has many posts, found by `posts.user_id`.
HasMany::<User, Post>::new()Implementations§
Source§impl<P, C> HasMany<P, C>
impl<P, C> HasMany<P, C>
Sourcepub fn new() -> HasMany<P, C>
pub fn new() -> HasMany<P, C>
With the conventional keys: posts.user_id matched against users.id.
Sourcepub fn foreign_key(self, column: impl Into<String>) -> HasMany<P, C>
pub fn foreign_key(self, column: impl Into<String>) -> HasMany<P, C>
The column on the child pointing back at the parent.
Sourcepub fn local_key(self, column: impl Into<String>) -> HasMany<P, C>
pub fn local_key(self, column: impl Into<String>) -> HasMany<P, C>
The column on the parent the child points at. Defaults to its key.
Sourcepub fn matching(self, criteria: Criteria) -> HasMany<P, C>
pub fn matching(self, criteria: Criteria) -> HasMany<P, C>
Narrow, order or limit the children — a constrained eager load.
A limit here limits the whole query, not each parent’s share: one
query cannot take the newest three per parent without a window function,
and pretending otherwise would silently drop rows.
Trait Implementations§
Source§impl<P, C> Relation<P> for HasMany<P, C>
impl<P, C> Relation<P> for HasMany<P, C>
Source§fn far_key(&self) -> &str
fn far_key(&self) -> &str
The column on the other side that this relationship matches against.
Source§fn load<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parents: &'life1 [P],
related: &'life2 (dyn Repository<C> + 'static),
) -> Pin<Box<dyn Future<Output = Result<Related<C>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
HasMany<P, C>: 'async_trait,
fn load<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parents: &'life1 [P],
related: &'life2 (dyn Repository<C> + 'static),
) -> Pin<Box<dyn Future<Output = Result<Related<C>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
HasMany<P, C>: 'async_trait,
Load the related rows for every parent, in one query.
Source§fn count<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parents: &'life1 [P],
related: &'life2 (dyn Repository<C> + 'static),
) -> Pin<Box<dyn Future<Output = Result<RelatedCounts, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
HasMany<P, C>: 'async_trait,
fn count<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parents: &'life1 [P],
related: &'life2 (dyn Repository<C> + 'static),
) -> Pin<Box<dyn Future<Output = Result<RelatedCounts, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
HasMany<P, C>: 'async_trait,
Count the related rows for every parent, in one query, without
transferring them.
Source§fn for_one<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parent: &'life1 P,
related: &'life2 (dyn Repository<Self::Related> + 'static),
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Related>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: Sized + 'async_trait,
fn for_one<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
parent: &'life1 P,
related: &'life2 (dyn Repository<Self::Related> + 'static),
) -> Pin<Box<dyn Future<Output = Result<Vec<Self::Related>, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: Sized + 'async_trait,
Load for a single parent. Read more
Auto Trait Implementations§
impl<P, C> Freeze for HasMany<P, C>
impl<P, C> RefUnwindSafe for HasMany<P, C>
impl<P, C> Send for HasMany<P, C>
impl<P, C> Sync for HasMany<P, C>
impl<P, C> Unpin for HasMany<P, C>
impl<P, C> UnsafeUnpin for HasMany<P, C>
impl<P, C> UnwindSafe for HasMany<P, C>
Blanket Implementations§
impl<T> Actor for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Event for T
impl<T> Event for T
Source§fn event_name() -> &'static strwhere
Self: Sized,
fn event_name() -> &'static strwhere
Self: Sized,
A human-readable name, used by wildcard listeners and log output.
Always the Rust type path; see the trait docs.
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 moreCreates a shared type from an unshared type.