English | 简体中文

api-docs / me.liuwj.ktorm.entity

Package me.liuwj.ktorm.entity

Entity supports, providing entity finding and sequence like query APIs.

Types

NameSummary

Entity

interface Entity<E : Entity<E>> : Serializable

The super interface of all entity classes in Ktorm. This interface injects many useful functions into entities.

EntityGrouping

data class EntityGrouping<E : Any, T : BaseTable<E>, K : Any>

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.

EntitySequence

data class EntitySequence<E : Any, T : BaseTable<E>>

Represents a sequence of entity objects. As the name implies, the style and use pattern of Ktorm’s entity sequence
APIs are highly similar to kotlin.sequences.Sequence and the extension functions in Kotlin standard lib, as it
provides many extension functions with the same names, such as filter, map, reduce, etc.

Functions

NameSummary

add

fun <E : Entity<E>> Table<E>.add(entity: E): Int

Insert the given entity into this table and return the affected record number.

aggregate

fun <E : Any, K : Any, R> EntityGrouping<E, , K>.aggregate(
    operation: (key: K?, accumulator: R?, element: E, first: Boolean) -> R
): Map<K?, R>

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially,
passing the previously accumulated value and the current element as arguments, and stores the results in a new map.

aggregateColumns

fun <E : Any, T : BaseTable<E>, K : Any, C : Any> EntityGrouping<E, T, K>.aggregateColumns(
    aggregationSelector: (T) -> ColumnDeclaring<C>
): Map<K?, C?>

Group elements from the source sequence by key and perform the given aggregation for elements in each group,
then store the results in a new Map.

fun <E : Any, T : BaseTable<E>, C : Any> EntitySequence<E, T>.aggregateColumns(
    aggregationSelector: (T) -> ColumnDeclaring<C>
): C?

Perform an aggregation given by aggregationSelector for all elements in the sequence,
and return the aggregate result.

aggregateColumnsTo

fun <E : Any, T : BaseTable<E>, K : Any, C : Any, M : MutableMap<in K?, in C?>> EntityGrouping<E, T, K>.aggregateColumnsTo(
    destination: M,
    aggregationSelector: (T) -> ColumnDeclaring<C>
): M

Group elements from the source sequence by key and perform the given aggregation for elements in each group,
then store the results in the destination map.

aggregateTo

fun <E : Any, K : Any, R, M : MutableMap<in K?, R>> EntityGrouping<E, , K>.aggregateTo(
    destination: M,
    operation: (key: K?, accumulator: R?, element: E, first: Boolean) -> R
): M

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially,
passing the previously accumulated value and the current element as arguments, and stores the results in the given
destination map.

all

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.all(
    predicate: (T) -> ColumnDeclaring<Boolean>
): Boolean

Return true if all elements match the given predicate.

any

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.any(): Boolean

Return true if the sequence has at lease one element.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.any(
    predicate: (T) -> ColumnDeclaring<Boolean>
): Boolean

Return true if at least one element matches the given predicate.

asSequence

fun <E : Any, T : BaseTable<E>> T.asSequence(): EntitySequence<E, T>

Create an EntitySequence, auto left joining all the reference tables.

asSequenceWithoutReferences

fun <E : Any, T : BaseTable<E>> T.asSequenceWithoutReferences(): EntitySequence<E, T>

Crete an EntitySequence without left joining reference tables.

associate

fun <E : Any, K, V> EntitySequence<E, >.associate(
    transform: (E) -> Pair<K, V>
): Map<K, V>

Return a Map containing key-value pairs provided by transform function applied to elements of the given sequence.

associateBy

fun <E : Any, K> EntitySequence<E, >.associateBy(
    keySelector: (E) -> K
): Map<K, E>

Return a Map containing the elements from the given sequence indexed by the key returned from keySelector
function applied to each element.

fun <E : Any, K, V> EntitySequence<E, >.associateBy(
    keySelector: (E) -> K,
    valueTransform: (E) -> V
): Map<K, V>

Return a Map containing the values provided by valueTransform and indexed by keySelector functions
applied to elements of the given sequence.

associateByTo

fun <E : Any, K, M : MutableMap<in K, in E>> EntitySequence<E, >.associateByTo(
    destination: M,
    keySelector: (E) -> K
): M

Populate and return the destination mutable map with key-value pairs, where key is provided by the keySelector
function applied to each element of the given sequence and value is the element itself.

fun <E : Any, K, V, M : MutableMap<in K, in V>> EntitySequence<E, >.associateByTo(
    destination: M,
    keySelector: (E) -> K,
    valueTransform: (E) -> V
): M

Populate and return the destination mutable map with key-value pairs, where key is provided by the keySelector
function and and value is provided by the valueTransform function applied to elements of the given sequence.

associateTo

fun <E : Any, K, V, M : MutableMap<in K, in V>> EntitySequence<E, >.associateTo(
    destination: M,
    transform: (E) -> Pair<K, V>
): M

Populate and return the destination mutable map with key-value pairs provided by transform function applied
to each element of the given sequence.

associateWith

fun <K : Entity<K>, V> EntitySequence<K, >.associateWith(
    valueSelector: (K) -> V
): Map<K, V>

Return a Map where keys are elements from the given sequence and values are produced by the valueSelector
function applied to each element.

associateWithTo

fun <K : Entity<K>, V, M : MutableMap<in K, in V>> EntitySequence<K, >.associateWithTo(
    destination: M,
    valueSelector: (K) -> V
): M

Populate and return the destination mutable map with key-value pairs for each element of the given sequence,
where key is the element itself and value is provided by the valueSelector function applied to that key.

averageBy

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.averageBy(
    selector: (T) -> ColumnDeclaring<out Number>
): Double?

Return the average value of the column given by selector in this sequence.

count

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.count(): Int

Return the number of elements in this sequence.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.count(
    predicate: (T) -> ColumnDeclaring<Boolean>
): Int

Return the number of elements matching the given predicate.

drop

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.drop(
    n: Int
): EntitySequence<E, T>

Returns a sequence containing all elements except first n elements.

eachAverageBy

fun <E : Any, T : BaseTable<E>, K : Any> EntityGrouping<E, T, K>.eachAverageBy(
    columnSelector: (T) -> ColumnDeclaring<out Number>
): Map<K?, Double?>

Group elements from the source sequence by key and average the columns or expressions provided by the
columnSelector function for elements in each group.

eachAverageByTo

fun <E : Any, T : BaseTable<E>, K : Any, M : MutableMap<in K?, in Double?>> EntityGrouping<E, T, K>.eachAverageByTo(
    destination: M,
    columnSelector: (T) -> ColumnDeclaring<out Number>
): M

Group elements from the source sequence by key and average the columns or expressions provided by the
columnSelector function for elements in each group, then store the results in the destination map.

eachCount

fun <E : Any, T : BaseTable<E>, K : Any> EntityGrouping<E, T, K>.eachCount(): Map<K?, Int>

Group elements from the source sequence by key and count elements in each group.

eachCountTo

fun <E : Any, T : BaseTable<E>, K : Any, M : MutableMap<in K?, Int>> EntityGrouping<E, T, K>.eachCountTo(
    destination: M
): M

Group elements from the source sequence by key and count elements in each group,
then store the results in the destination map.

eachMaxBy

fun <E : Any, T : BaseTable<E>, K : Any, C : Comparable<C>> EntityGrouping<E, T, K>.eachMaxBy(
    columnSelector: (T) -> ColumnDeclaring<C>
): Map<K?, C?>

Group elements from the source sequence by key and get the max value of the columns or expressions provided by the
columnSelector function for elements in each group.

eachMaxByTo

fun <E : Any, T : BaseTable<E>, K : Any, C : Comparable<C>, M : MutableMap<in K?, in C?>> EntityGrouping<E, T, K>.eachMaxByTo(
    destination: M,
    columnSelector: (T) -> ColumnDeclaring<C>
): M

Group elements from the source sequence by key and get the max value of the columns or expressions provided by the
columnSelector function for elements in each group, then store the results in the destination map.

eachMinBy

fun <E : Any, T : BaseTable<E>, K : Any, C : Comparable<C>> EntityGrouping<E, T, K>.eachMinBy(
    columnSelector: (T) -> ColumnDeclaring<C>
): Map<K?, C?>

Group elements from the source sequence by key and get the min value of the columns or expressions provided by the
columnSelector function for elements in each group.

eachMinByTo

fun <E : Any, T : BaseTable<E>, K : Any, C : Comparable<C>, M : MutableMap<in K?, in C?>> EntityGrouping<E, T, K>.eachMinByTo(
    destination: M,
    columnSelector: (T) -> ColumnDeclaring<C>
): M

Group elements from the source sequence by key and get the min value of the columns or expressions provided by the
columnSelector function for elements in each group, then store the results in the destination map.

eachSumBy

fun <E : Any, T : BaseTable<E>, K : Any, C : Number> EntityGrouping<E, T, K>.eachSumBy(
    columnSelector: (T) -> ColumnDeclaring<C>
): Map<K?, C?>

Group elements from the source sequence by key and sum the columns or expressions provided by the columnSelector
function for elements in each group.

eachSumByTo

fun <E : Any, T : BaseTable<E>, K : Any, C : Number, M : MutableMap<in K?, in C?>> EntityGrouping<E, T, K>.eachSumByTo(
    destination: M,
    columnSelector: (T) -> ColumnDeclaring<C>
): M

Group elements from the source sequence by key and sum the columns or expressions provided by the columnSelector
function for elements in each group, then store the results in the destination map.

elementAt

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.elementAt(
    index: Int
): E

Return an element at the given index or throws an IndexOutOfBoundsException if the index is out of bounds
of this sequence.

elementAtOrElse

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.elementAtOrElse(
    index: Int,
    defaultValue: (Int) -> E
): E

Return an element at the given index or the result of calling the defaultValue function if the index is out
of bounds of this sequence.

elementAtOrNull

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.elementAtOrNull(
    index: Int
): E?

Return an element at the given index or null if the index is out of bounds of this sequence.

filter

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.filter(
    predicate: (T) -> ColumnDeclaring<Boolean>
): EntitySequence<E, T>

Return a sequence containing only elements matching the given predicate.

filterColumns

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.filterColumns(
    selector: (T) -> List<Column<>>
): EntitySequence<E, T>

Return a sequence customizing the selected columns of the internal query.

filterNot

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.filterNot(
    predicate: (T) -> ColumnDeclaring<Boolean>
): EntitySequence<E, T>

Return a sequence containing only elements not matching the given predicate.

filterNotTo

fun <E : Any, T : BaseTable<E>, C : MutableCollection<in E>> EntitySequence<E, T>.filterNotTo(
    destination: C,
    predicate: (T) -> ColumnDeclaring<Boolean>
): C

Append all elements not matching the given predicate to the given destination.

filterTo

fun <E : Any, T : BaseTable<E>, C : MutableCollection<in E>> EntitySequence<E, T>.filterTo(
    destination: C,
    predicate: (T) -> ColumnDeclaring<Boolean>
): C

Append all elements matching the given predicate to the given destination.

find

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.find(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E?

Return the first element matching the given predicate, or null if no such element was found.

findAll

fun <E : Any> BaseTable<E>.findAll(): List<E>

Obtain all the entity objects from this table, auto left joining all the reference tables.

findById

fun <E : Any> BaseTable<E>.findById(id: Any): E?

Obtain a entity object by its ID, auto left joining all the reference tables.

findLast

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.findLast(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E?

Return the last element matching the given predicate, or null if no such element was found.

findList

fun <E : Any, T : BaseTable<E>> T.findList(
    predicate: (T) -> ColumnDeclaring<Boolean>
): List<E>

Obtain a list of entity objects matching the given predicate, auto left joining all the reference tables.

findListByIds

fun <E : Any> BaseTable<E>.findListByIds(
    ids: Collection<Any>
): List<E>

Obtain a list of entity objects by IDs, auto left joining all the reference tables.

findMapByIds

fun <E : Entity<E>, K : Any> Table<E>.findMapByIds(
    ids: Collection<K>
): Map<K, E>

Obtain a map of entity objects by IDs, auto left joining all the reference tables.

findOne

fun <E : Any, T : BaseTable<E>> T.findOne(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E?

Obtain a entity object matching the given predicate, auto left joining all the reference tables.

first

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.first(): E

Return the first element, or throws NoSuchElementException if the sequence is empty.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.first(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E

Return the first element matching the given predicate, or throws NoSuchElementException if element was not found.

firstOrNull

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.firstOrNull(): E?

Return the first element, or null if the sequence is empty.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.firstOrNull(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E?

Return the first element matching the given predicate, or null if element was not found.

fold

fun <E : Any, K : Any, R> EntityGrouping<E, , K>.fold(
    initialValueSelector: (key: K?, element: E) -> R,
    operation: (key: K?, accumulator: R, element: E) -> R
): Map<K?, R>

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially,
passing the previously accumulated value and the current element as arguments, and stores the results in a new map.
An initial value of accumulator is provided by initialValueSelector function.

fun <E : Any, K : Any, R> EntityGrouping<E, , K>.fold(
    initialValue: R,
    operation: (accumulator: R, element: E) -> R
): Map<K?, R>

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially,
passing the previously accumulated value and the current element as arguments, and stores the results in a new map.
An initial value of accumulator is the same initialValue for each group.

fun <E : Any, R> EntitySequence<E, >.fold(
    initial: R,
    operation: (acc: R, E) -> R
): R

Accumulate value starting with initial value and applying operation from left to right to current accumulator
value and each element.

foldIndexed

fun <E : Any, R> EntitySequence<E, >.foldIndexed(
    initial: R,
    operation: (index: Int, acc: R, E) -> R
): R

Accumulate value starting with initial value and applying operation from left to right to current accumulator
value and each element with its index in the original sequence.

foldTo

fun <E : Any, K : Any, R, M : MutableMap<in K?, R>> EntityGrouping<E, , K>.foldTo(
    destination: M,
    initialValueSelector: (key: K?, element: E) -> R,
    operation: (key: K?, accumulator: R, element: E) -> R
): M

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially,
passing the previously accumulated value and the current element as arguments, and stores the results in the given
destination map. An initial value of accumulator is provided by initialValueSelector function.

fun <E : Any, K : Any, R, M : MutableMap<in K?, R>> EntityGrouping<E, , K>.foldTo(
    destination: M,
    initialValue: R,
    operation: (accumulator: R, element: E) -> R
): M

Groups elements from the source sequence by key and applies operation to the elements of each group sequentially,
passing the previously accumulated value and the current element as arguments, and stores the results in the given
destination map. An initial value of accumulator is the same initialValue for each group.

forEach

fun <E : Any> EntitySequence<E, >.forEach(
    action: (E) -> Unit
): Unit

Perform the given action on each element.

forEachIndexed

fun <E : Any> EntitySequence<E, >.forEachIndexed(
    action: (index: Int, E) -> Unit
): Unit

Perform the given action on each element, providing sequential index with the element.

groupBy

fun <E : Any, K> EntitySequence<E, >.groupBy(
    keySelector: (E) -> K
): Map<K, List<E>>

Group elements of the original sequence by the key returned by the given keySelector function applied to each
element and return a map where each group key is associated with a list of corresponding elements.

fun <E : Any, K, V> EntitySequence<E, >.groupBy(
    keySelector: (E) -> K,
    valueTransform: (E) -> V
): Map<K, List<V>>

Group values returned by the valueTransform function applied to each element of the original sequence by the key
returned by the given keySelector function applied to the element and returns a map where each group key is
associated with a list of corresponding values.

groupByTo

fun <E : Any, K, M : MutableMap<in K, MutableList<E>>> EntitySequence<E, >.groupByTo(
    destination: M,
    keySelector: (E) -> K
): M

Group elements of the original sequence by the key returned by the given keySelector function applied to each
element and put to the destination map each group key associated with a list of corresponding elements.

fun <E : Any, K, V, M : MutableMap<in K, MutableList<V>>> EntitySequence<E, >.groupByTo(
    destination: M,
    keySelector: (E) -> K,
    valueTransform: (E) -> V
): M

Group values returned by the valueTransform function applied to each element of the original sequence by the key
returned by the given keySelector function applied to the element and put to the destination map each group key
associated with a list of corresponding values.

groupingBy

fun <E : Any, T : BaseTable<E>, K : Any> EntitySequence<E, T>.groupingBy(
    keySelector: (T) -> ColumnDeclaring<K>
): EntityGrouping<E, T, K>

Create an EntityGrouping from the sequence to be used later with one of group-and-fold operations.

joinReferencesAndSelect

fun BaseTable<>.joinReferencesAndSelect(): Query

Return a new-created Query object, left joining all the reference tables, and selecting all columns of them.

joinTo

fun <E : Any, A> EntitySequence<E, >.joinTo(
    buffer: A,
    separator: CharSequence = ”, “,
    prefix: CharSequence = ””,
    postfix: CharSequence = ””,
    limit: Int = -1,
    truncated: CharSequence = ”…”,
    transform: ((E) -> CharSequence)? = null
): A

Append the string from all the elements separated using separator and using the given prefix and postfix.

joinToString

fun <E : Any> EntitySequence<E, >.joinToString(
    separator: CharSequence = ”, “,
    prefix: CharSequence = ””,
    postfix: CharSequence = ””,
    limit: Int = -1,
    truncated: CharSequence = ”…”,
    transform: ((E) -> CharSequence)? = null
): String

Create a string from all the elements separated using separator and using the given prefix and postfix.

last

fun <E : Any> EntitySequence<E, >.last(): E

Return the last element, or throws NoSuchElementException if the sequence is empty.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.last(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E

Return the last element matching the given predicate, or throws NoSuchElementException if no such element found.

lastOrNull

fun <E : Any> EntitySequence<E, >.lastOrNull(): E?

Return the last element, or null if the sequence is empty.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.lastOrNull(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E?

Return the last element matching the given predicate, or null if no such element was found.

map

fun <E : Any, R> EntitySequence<E, >.map(
    transform: (E) -> R
): List<R>

Return a List containing the results of applying the given transform function
to each element in the original sequence.

mapColumns

fun <E : Any, T : BaseTable<E>, C : Any> EntitySequence<E, T>.mapColumns(
    isDistinct: Boolean = false,
    columnSelector: (T) -> ColumnDeclaring<C>
): List<C?>

Customize the selected columns of the internal query by the given columnSelector function, and return a List
containing the query results.

mapColumnsNotNull

fun <E : Any, T : BaseTable<E>, C : Any> EntitySequence<E, T>.mapColumnsNotNull(
    isDistinct: Boolean = false,
    columnSelector: (T) -> ColumnDeclaring<C>
): List<C>

Customize the selected columns of the internal query by the given columnSelector function, and return a List
containing the non-null results.

mapColumnsNotNullTo

fun <E : Any, T : BaseTable<E>, C : Any, R : MutableCollection<in C>> EntitySequence<E, T>.mapColumnsNotNullTo(
    destination: R,
    isDistinct: Boolean = false,
    columnSelector: (T) -> ColumnDeclaring<C>
): R

Customize the selected columns of the internal query by the given columnSelector function, and append non-null
results to the given destination.

mapColumnsTo

fun <E : Any, T : BaseTable<E>, C : Any, R : MutableCollection<in C?>> EntitySequence<E, T>.mapColumnsTo(
    destination: R,
    isDistinct: Boolean = false,
    columnSelector: (T) -> ColumnDeclaring<C>
): R

Customize the selected columns of the internal query by the given columnSelector function, and append the query
results to the given destination.

mapIndexed

fun <E : Any, R> EntitySequence<E, >.mapIndexed(
    transform: (index: Int, E) -> R
): List<R>

Return a List containing the results of applying the given transform function
to each element and its index in the original sequence.

mapIndexedTo

fun <E : Any, R, C : MutableCollection<in R>> EntitySequence<E, >.mapIndexedTo(
    destination: C,
    transform: (index: Int, E) -> R
): C

Apply the given transform function to each element and its index in the original sequence
and append the results to the given destination.

mapTo

fun <E : Any, R, C : MutableCollection<in R>> EntitySequence<E, >.mapTo(
    destination: C,
    transform: (E) -> R
): C

Apply the given transform function to each element of the original sequence
and append the results to the given destination.

maxBy

fun <E : Any, T : BaseTable<E>, C : Comparable<C>> EntitySequence<E, T>.maxBy(
    selector: (T) -> ColumnDeclaring<C>
): C?

Return the max value of the column given by selector in this sequence.

minBy

fun <E : Any, T : BaseTable<E>, C : Comparable<C>> EntitySequence<E, T>.minBy(
    selector: (T) -> ColumnDeclaring<C>
): C?

Return the min value of the column given by selector in this sequence.

none

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.none(): Boolean

Return true if the sequence has no elements.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.none(
    predicate: (T) -> ColumnDeclaring<Boolean>
): Boolean

Return true if no elements match the given predicate.

reduce

fun <E : Any, K : Any> EntityGrouping<E, , K>.reduce(
    operation: (key: K?, accumulator: E, element: E) -> E
): Map<K?, E>

Groups elements from the source sequence by key and applies the reducing operation to the elements of each group
sequentially starting from the second element of the group, passing the previously accumulated value and the current
element as arguments, and stores the results in a new map. An initial value of accumulator is the first element of
the group.

fun <E : Any> EntitySequence<E, >.reduce(
    operation: (acc: E, E) -> E
): E

Accumulate value starting with the first element and applying operation from left to right to current accumulator
value and each element.

reduceIndexed

fun <E : Any> EntitySequence<E, >.reduceIndexed(
    operation: (index: Int, acc: E, E) -> E
): E

Accumulate value starting with the first element and applying operation from left to right to current accumulator
value and each element with its index in the original sequence.

reduceTo

fun <E : Any, K : Any, M : MutableMap<in K?, E>> EntityGrouping<E, , K>.reduceTo(
    destination: M,
    operation: (key: K?, accumulator: E, element: E) -> E
): M

Groups elements from the source sequence by key and applies the reducing operation to the elements of each group
sequentially starting from the second element of the group, passing the previously accumulated value and the current
element as arguments, and stores the results in the given destination map. An initial value of accumulator is the
first element of the group.

single

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.single(): E

Return the single element, or throws an exception if the sequence is empty or has more than one element.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.single(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E

Return the single element matching the given predicate, or throws exception if there is no or more than one
matching element.

singleOrNull

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.singleOrNull(): E?

Return single element, or null if the sequence is empty or has more than one element.

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.singleOrNull(
    predicate: (T) -> ColumnDeclaring<Boolean>
): E?

Return the single element matching the given predicate, or null if element was not found or more than one
element was found.

sorted

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.sorted(
    selector: (T) -> List<OrderByExpression>
): EntitySequence<E, T>

Return a sequence customizing the order by clause of the internal query.

sortedBy

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.sortedBy(
    selector: (T) -> ColumnDeclaring<>
): EntitySequence<E, T>

Return a sequence sorting elements by the specific column in ascending order.

sortedByDescending

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.sortedByDescending(
    selector: (T) -> ColumnDeclaring<>
): EntitySequence<E, T>

Return a sequence sorting elements by the specific column in descending order.

sumBy

fun <E : Any, T : BaseTable<E>, C : Number> EntitySequence<E, T>.sumBy(
    selector: (T) -> ColumnDeclaring<C>
): C?

Return the sum of the column given by selector in this sequence.

take

fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.take(
    n: Int
): EntitySequence<E, T>

Returns a sequence containing first n elements.

toCollection

fun <E : Any, C : MutableCollection<in E>> EntitySequence<E, >.toCollection(
    destination: C
): C

Append all elements to the given destination collection.

toHashSet

fun <E : Any> EntitySequence<E, >.toHashSet(): HashSet<E>

Return a HashSet containing all the elements of this sequence.

toList

fun <E : Any> EntitySequence<E, >.toList(): List<E>

Return a List containing all the elements of this sequence.

toMutableList

fun <E : Any> EntitySequence<E, >.toMutableList(): MutableList<E>

Return a MutableList containing all the elements of this sequence.

toMutableSet

fun <E : Any> EntitySequence<E, >.toMutableSet(): MutableSet<E>

Return a MutableSet containing all the elements of this sequence.

toSet

fun <E : Any> EntitySequence<E, >.toSet(): Set<E>

Return a Set containing all the elements of this sequence.

toSortedSet

fun <E> EntitySequence<E, >.toSortedSet(): SortedSet<E> where E : Any, E : Comparable<E>

fun <E> EntitySequence<E, >.toSortedSet(
    comparator: Comparator<in E>
): SortedSet<E> where E : Any, E : Comparable<E>

Return a SortedSet containing all the elements of this sequence.