pub struct RelationLoader<E: QueryEngine> { /* private fields */ }Expand description
Relation loader for executing relation queries.
Implementations§
Source§impl<E: QueryEngine> RelationLoader<E>
impl<E: QueryEngine> RelationLoader<E>
Sourcepub fn with_strategy(self, strategy: RelationLoadStrategy) -> Self
pub fn with_strategy(self, strategy: RelationLoadStrategy) -> Self
Set the loading strategy.
Sourcepub fn with_batch_size(self, size: usize) -> Self
pub fn with_batch_size(self, size: usize) -> Self
Set the batch size for separate queries.
Used by Self::build_one_to_many_queries to chunk parent IDs into
bounded IN (...) lists, one statement per chunk.
Sourcepub fn build_one_to_many_query(
&self,
spec: &RelationSpec,
include: &IncludeSpec,
parent_ids: &[FilterValue],
) -> (String, Vec<FilterValue>)
pub fn build_one_to_many_query( &self, spec: &RelationSpec, include: &IncludeSpec, parent_ids: &[FilterValue], ) -> (String, Vec<FilterValue>)
Build a query for loading a one-to-many relation.
Placeholders and the nested Filter::to_sql call are emitted through
the engine’s dialect (QueryEngine::dialect()), so the statement
matches the connected backend.
Sourcepub fn build_one_to_many_queries(
&self,
spec: &RelationSpec,
include: &IncludeSpec,
parent_ids: &[FilterValue],
) -> Vec<(String, Vec<FilterValue>)>
pub fn build_one_to_many_queries( &self, spec: &RelationSpec, include: &IncludeSpec, parent_ids: &[FilterValue], ) -> Vec<(String, Vec<FilterValue>)>
Build one-to-many queries batched by Self::with_batch_size.
Chunks parent_ids into groups of at most batch_size and emits one
statement per chunk — ceil(N / batch_size) statements — keeping each
IN (...) list bounded. Callers using the separate-query strategy
should execute every statement and merge the results.
Sourcepub fn build_many_to_one_query(
&self,
spec: &RelationSpec,
child_foreign_keys: &[FilterValue],
) -> (String, Vec<FilterValue>)
pub fn build_many_to_one_query( &self, spec: &RelationSpec, child_foreign_keys: &[FilterValue], ) -> (String, Vec<FilterValue>)
Build a query for loading a many-to-one relation.
Sourcepub fn build_many_to_many_query(
&self,
spec: &RelationSpec,
include: &IncludeSpec,
parent_ids: &[FilterValue],
) -> (String, Vec<FilterValue>)
pub fn build_many_to_many_query( &self, spec: &RelationSpec, include: &IncludeSpec, parent_ids: &[FilterValue], ) -> (String, Vec<FilterValue>)
Build a query for loading a many-to-many relation.