← Back to Stormify Documentation

PagedAggregator

Entry point for the aggregation DSL on a PagedListBase.

Each builder method registers one aggregate and returns a SingleAggregator — a view that can either be executed immediately for a single scalar value (.execute<BigDecimal>()) or chained into additional aggregations to produce a MultiAggregator (whose execute() returns a Map keyed by alias).

Aggregations inherit the parent list's constraints and per-column filters — list.getColumn(0).filter = "Acme" is honored by sum/avg/… — but the isDistinct flag is ignored for aggregates.

val list = PagedList<Company>()
stormify.attach(list)
list.addColumn("industry").filter = "Tech"

// Single value
val total: BigDecimal? = list.getAggregator()
.sum(Company_.revenue)
.execute<BigDecimal>()

// Multiple values
val row: Map<String, Any?> = list.getAggregator()
.sum(Company_.revenue, "total")
.avg(Company_.revenue, "average")
.count("*", "cnt")
.execute()

Functions

Link copied to clipboard
fun avg(path: String, alias: String? = null): SingleAggregator

Starts an AVG(path) aggregation.

fun avg(path: ScalarPath, alias: String? = null): SingleAggregator

Starts an AVG(path) aggregation using a type-safe ScalarPath.

Link copied to clipboard
fun count(path: String, alias: String? = null): SingleAggregator

Starts a COUNT(path) aggregation. Pass "*" for COUNT(*).

Starts a COUNT(path) aggregation using a type-safe ScalarPath.

Link copied to clipboard

Starts a COUNT(DISTINCT path) aggregation.

Starts a COUNT(DISTINCT path) aggregation using a type-safe ScalarPath.

Link copied to clipboard
fun max(path: String, alias: String? = null): SingleAggregator

Starts a MAX(path) aggregation.

fun max(path: ScalarPath, alias: String? = null): SingleAggregator

Starts a MAX(path) aggregation using a type-safe ScalarPath.

Link copied to clipboard
fun min(path: String, alias: String? = null): SingleAggregator

Starts a MIN(path) aggregation.

fun min(path: ScalarPath, alias: String? = null): SingleAggregator

Starts a MIN(path) aggregation using a type-safe ScalarPath.

Link copied to clipboard
fun raw(expression: String, alias: String? = null): SingleAggregator

Starts an aggregation from an arbitrary SQL expression. The expression is emitted verbatim into the generated SELECT list — callers are responsible for writing safe, dialect-compatible SQL.

Link copied to clipboard
fun sum(path: String, alias: String? = null): SingleAggregator

Starts a SUM(path) aggregation.

fun sum(path: ScalarPath, alias: String? = null): SingleAggregator

Starts a SUM(path) aggregation using a type-safe ScalarPath.