Projections & Aggregates
var statusReport = c
.withProjections( count: "isActive:authors", groupProperty: "isActive" )
.asStruct()
.list();withProjections()
/**
* Setup projections for this criteria query, you can pass one or as many projection arguments as you like.
* The majority of the arguments take in the property name to do the projection on, which will also use that as the alias for the column
* or you can pass an alias after the property name separated by a : Ex: projections(avg="balance:avgBalance")
* The alias on the projected value can be referred to in restrictions or orderings.
* Please also note that the resulting array locations are done in alphabetical order of the arguments.
*
* @avg The name of the property to avg or a list or array of property names
* @count The name of the property to count or a list or array of property names
* @countDistinct The name of the property to count distinct or a list or array of property names
* @distinct The name of the property to do a distinct on, this can be a single property name a list or an array of property names
* @groupProperty The name of the property to group by or a list or array of property names
* @id The projected identifier value
* @max The name of the property to max or a list or array of property names
* @min The name of the property to min or a list or array of property names
* @property The name of the property to do a projected value on or a list or array of property names
* @rowCount Do a row count on the criteria
* @sum The name of the property to sum or a list or array of property names
* @sqlProjection Do a projection based on arbitrary SQL string
* @sqlGroupProjection Do a projection based on arbitrary SQL string, with grouping
* @detachedSQLProjection Do a projection based on a DetachedCriteria builder config
*/
any function withProjections(
string avg,
string count,
string countDistinct,
any distinct,
string groupProperty,
boolean id,
string max,
string min,
string property,
boolean rowCount,
string sum,
any sqlProjection,
any sqlGroupProjection,
any detachedSQLProjection
){Arguments
Transform
Description
Example
Aliases
Examples
Projections
avg
count
countDistinct
distinct
groupProperty
id
max
min
property
rowcount
sum
sqlProjection/sqlGroupProjection
Last updated
Was this helpful?