pub struct QueryBuilderWithEagerLoading<M> { /* private fields */ }Expand description
QueryBuilder enhanced with eager loading capabilities
Implementations§
Source§impl<M> QueryBuilderWithEagerLoading<M>
impl<M> QueryBuilderWithEagerLoading<M>
Sourcepub fn new(query: QueryBuilder<M>) -> Self
pub fn new(query: QueryBuilder<M>) -> Self
Create a new query builder with eager loading from a base query
Sourcepub fn with_where<F>(self, relation: &str, constraint: F) -> Self
pub fn with_where<F>(self, relation: &str, constraint: F) -> Self
Add a relationship with constraints
Sourcepub fn with_count(self, relation: &str) -> Self
pub fn with_count(self, relation: &str) -> Self
Load relationship counts without loading the relationships
Sourcepub fn with_count_where<F>(
self,
alias: &str,
relation: &str,
_constraint: F,
) -> Self
pub fn with_count_where<F>( self, alias: &str, relation: &str, _constraint: F, ) -> Self
Load relationship counts with constraints and custom alias
Sourcepub async fn get(self, pool: &Pool<Postgres>) -> ModelResult<Vec<M>>
pub async fn get(self, pool: &Pool<Postgres>) -> ModelResult<Vec<M>>
Execute the query and return models with eagerly loaded relationships
Sourcepub async fn first(self, pool: &Pool<Postgres>) -> ModelResult<Option<M>>
pub async fn first(self, pool: &Pool<Postgres>) -> ModelResult<Option<M>>
Execute the query and return the first model with eagerly loaded relationships
Sourcepub async fn first_or_fail(self, pool: &Pool<Postgres>) -> ModelResult<M>
pub async fn first_or_fail(self, pool: &Pool<Postgres>) -> ModelResult<M>
Execute the query and return the first model or fail
Sourcepub fn where_condition<V>(self, field: &str, operator: &str, value: V) -> Self
pub fn where_condition<V>(self, field: &str, operator: &str, value: V) -> Self
Add WHERE conditions with custom operator
Sourcepub fn order_by_desc(self, field: &str) -> Self
pub fn order_by_desc(self, field: &str) -> Self
Add ORDER BY DESC to the base query
Sourcepub fn optimize_loading(self) -> Self
pub fn optimize_loading(self) -> Self
Enable optimized loading with advanced query optimization
Sourcepub fn optimize_loading_with_config(self, config: EagerLoadConfig) -> Self
pub fn optimize_loading_with_config(self, config: EagerLoadConfig) -> Self
Enable optimized loading with custom configuration
Sourcepub fn batch_size(self, size: usize) -> Self
pub fn batch_size(self, size: usize) -> Self
Set custom batch size for relationship loading
Sourcepub fn parallel_loading(self, enabled: bool) -> Self
pub fn parallel_loading(self, enabled: bool) -> Self
Enable parallel execution for relationship loading
Auto Trait Implementations§
impl<M> Freeze for QueryBuilderWithEagerLoading<M>
impl<M> !RefUnwindSafe for QueryBuilderWithEagerLoading<M>
impl<M> Send for QueryBuilderWithEagerLoading<M>where
M: Send,
impl<M> Sync for QueryBuilderWithEagerLoading<M>where
M: Sync,
impl<M> Unpin for QueryBuilderWithEagerLoading<M>where
M: Unpin,
impl<M> !UnwindSafe for QueryBuilderWithEagerLoading<M>
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
Mutably borrows from an owned value. Read more
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 more