English | 简体中文

api-docs / org.ktorm.entity / EntityGrouping / <init>

<init>

EntityGrouping(
    sequence: EntitySequence<E, T>,
    keySelector: (T) -> ColumnDeclaring<K>)

Wraps an EntitySequence with a keySelector function, which can be applied to each record to get its key,
or used as the group by clause of the generated SQL.

An EntityGrouping structure serves as an intermediate step in group-and-fold operations: they group elements
by their keys and then fold each group with some aggregation operation.

Entity groups are created by attaching keySelector: (T) -> ColumnDeclaring<K> function to an entity sequence.
To get an instance of EntityGrouping, use the extension function EntitySequence.groupingBy.

For the list of group-and-fold operations available, see the extension functions below.