#[non_exhaustive]pub enum Aggregation<E: Entity> {
Count(E::Column, bool),
Sum(E::Column),
Avg(E::Column),
Min(E::Column),
Max(E::Column),
Stddev(E::Column),
Variance(E::Column),
JsonArrayagg(E::Column),
JsonObjectagg(E::Column, E::Column),
}Expand description
SQL aggregate expressions.
§Examples
ⓘ
use crate::model::{Task, TaskColumn};
use zino_core::Map;
use zino_orm::{Aggregation, QueryBuilder, Schema};
let query = QueryBuilder::new()
.aggregate(Aggregation::Count(TaskColumn::Id, false), "num_tasks")
.aggregate(Aggregation::Sum(TaskColumn::Manhours), "total_manhours")
.aggregate(Aggregation::Avg(TaskColumn::Manhours), "average_manhours")
.and_eq(TaskColumn::Status, "Completed")
.group_by(TaskColumn::ProjectId, "project_id")
.having_ge(Aggregation::Avg(TaskColumn::Manhours), 50)
.order_desc("total_manhours")
.limit(10)
.build();
let entries = Task::aggregate::<Map>(&query).await?;Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Count(E::Column, bool)
The COUNT function with the DISTINCT modifier.
Sum(E::Column)
The SUM function.
Avg(E::Column)
The AVG function.
Min(E::Column)
The MIN function.
Max(E::Column)
The MAX function.
Stddev(E::Column)
The STDDEV function.
Variance(E::Column)
The VARIANCE function.
JsonArrayagg(E::Column)
The JSON_ARRAYAGG function.
JsonObjectagg(E::Column, E::Column)
The JSON_OBJECTAGG function.
Trait Implementations§
Source§impl<E: Clone + Entity> Clone for Aggregation<E>
impl<E: Clone + Entity> Clone for Aggregation<E>
Source§fn clone(&self) -> Aggregation<E>
fn clone(&self) -> Aggregation<E>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl<E: Copy + Entity> Copy for Aggregation<E>
Auto Trait Implementations§
impl<E> Freeze for Aggregation<E>
impl<E> RefUnwindSafe for Aggregation<E>
impl<E> Send for Aggregation<E>
impl<E> Sync for Aggregation<E>
impl<E> Unpin for Aggregation<E>
impl<E> UnwindSafe for Aggregation<E>
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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