EntitySequence

class EntitySequence<E : Any, T : BaseTable<E>>(val database: Database, val sourceTable: T, val expression: SelectExpression, val entityExtractor: (row: QueryRowSet) -> E)(source)

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.

To create an EntitySequence, we can use the extension function sequenceOf:

val sequence = database.sequenceOf(Employees)

Now we got a default sequence, which can obtain all employees from the table. Please know that Ktorm doesn't execute the query right now. The sequence provides an iterator of type Iterator<Employee>, only when we iterate the sequence using the iterator, the query is executed. The following code prints all employees using a for-each loop:

for (employee in sequence) {
println(employee)
}

This class wraps a Query object, and it’s iterator exactly wraps the query’s iterator. When an entity sequence is iterated, its internal query is executed, and the entityExtractor function is applied to create an entity object for each row.

Most of the entity sequence APIs are provided as extension functions, which can be divided into two groups:

  • Intermediate operations: these functions don’t execute the internal queries but return new-created sequence objects applying some modifications. For example, the filter function creates a new sequence object with the filter condition given by its parameter. The return types of intermediate operations are usually EntitySequence, so we can call other sequence functions continuously in chaining style.

  • Terminal operations: the return types of these functions are usually a collection or a computed result, as they execute the queries right now, obtain their results and perform some calculations on them. E.g. toList, reduce, etc.

For the list of sequence operations available, see the extension functions below.

Constructors

Link copied to clipboard
constructor(database: Database, sourceTable: T, expression: SelectExpression, entityExtractor: (row: QueryRowSet) -> E)

Properties

Link copied to clipboard

The Database instance that the internal query is running on.

Link copied to clipboard

The function used to extract entity objects for each result row.

Link copied to clipboard

The SQL expression to be executed by this sequence when obtaining elements.

Link copied to clipboard

The internal query of this sequence to be executed, created by database and expression.

Link copied to clipboard

The ResultSet object of the internal query, lazy initialized after first access, obtained from the database by executing the generated SQL.

Link copied to clipboard

The source table from which elements are obtained.

Link copied to clipboard
val sql: String

The executable SQL string of the internal query.

Link copied to clipboard

The total records count of this query ignoring the pagination params.

Link copied to clipboard

The total records count of this query ignoring the pagination params.

Functions

Link copied to clipboard
fun <E : Entity<E>, T : Table<E>> EntitySequence<E, T>.add(entity: E): Int

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

Link copied to clipboard
@JvmName(name = "_aggregateColumns2")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any> EntitySequence<E, T>.aggregateColumns(aggregationSelector: (T) -> Tuple2<ColumnDeclaring<C1>, ColumnDeclaring<C2>>): Tuple2<C1?, C2?>
@JvmName(name = "_aggregateColumns3")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any> EntitySequence<E, T>.aggregateColumns(aggregationSelector: (T) -> Tuple3<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>>): Tuple3<C1?, C2?, C3?>
@JvmName(name = "_aggregateColumns4")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any> EntitySequence<E, T>.aggregateColumns(aggregationSelector: (T) -> Tuple4<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>>): Tuple4<C1?, C2?, C3?, C4?>
@JvmName(name = "_aggregateColumns5")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any> EntitySequence<E, T>.aggregateColumns(aggregationSelector: (T) -> Tuple5<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>>): Tuple5<C1?, C2?, C3?, C4?, C5?>
@JvmName(name = "_aggregateColumns6")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any> EntitySequence<E, T>.aggregateColumns(aggregationSelector: (T) -> Tuple6<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>>): Tuple6<C1?, C2?, C3?, C4?, C5?, C6?>
@JvmName(name = "_aggregateColumns7")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any> EntitySequence<E, T>.aggregateColumns(aggregationSelector: (T) -> Tuple7<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>>): Tuple7<C1?, C2?, C3?, C4?, C5?, C6?, C7?>
@JvmName(name = "_aggregateColumns8")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any> EntitySequence<E, T>.aggregateColumns(aggregationSelector: (T) -> Tuple8<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>>): Tuple8<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?>
@JvmName(name = "_aggregateColumns9")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any, C9 : Any> EntitySequence<E, T>.aggregateColumns(aggregationSelector: (T) -> Tuple9<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>, ColumnDeclaring<C9>>): Tuple9<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?>

Perform a tuple of aggregations given by aggregationSelector for all elements in the sequence, and return the aggregate results.

inline 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.

Link copied to clipboard
inline fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.all(predicate: (T) -> ColumnDeclaring<Boolean>): Boolean

Return true if all elements match the given predicate.

Link copied to clipboard

Return true if the sequence has at lease one element.

inline 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.

Link copied to clipboard

Create a kotlin.sequences.Sequence instance that wraps this original entity sequence returning all the elements when being iterated.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

inline 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.

Link copied to clipboard
inline 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.

inline 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 value is provided by the valueTransform function applied to elements of the given sequence.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.clear(): Int

Remove all the elements of this sequence. The sequence will be empty after this function returns.

Link copied to clipboard
fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.count(): Int

Return the number of elements in this sequence.

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

Return the number of elements matching the given predicate.

Link copied to clipboard

Returns a sequence containing all elements except first n elements.

Link copied to clipboard
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.

Link copied to clipboard
inline 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.

Link copied to clipboard
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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.first(): E

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

inline 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.

Link copied to clipboard

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

inline 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.

Link copied to clipboard
inline fun <E : Any, R> EntitySequence<E, *>.flatMap(transform: (E) -> Iterable<R>): List<R>

Return a single list of all elements yielded from results of transform function being invoked on each element of original sequence.

Link copied to clipboard
inline fun <E : Any, R> EntitySequence<E, *>.flatMapIndexed(transform: (index: Int, E) -> Iterable<R>): List<R>

Return a single list of all elements yielded from results of transform function being invoked on each element and its index in the original sequence.

Link copied to clipboard
inline fun <E : Any, R, C : MutableCollection<in R>> EntitySequence<E, *>.flatMapIndexedTo(destination: C, transform: (index: Int, E) -> Iterable<R>): C

Append all elements yielded from results of transform function being invoked on each element and its index in the original sequence, to the given destination.

Link copied to clipboard
inline fun <E : Any, R, C : MutableCollection<in R>> EntitySequence<E, *>.flatMapTo(destination: C, transform: (E) -> Iterable<R>): C

Append all elements yielded from results of transform function being invoked on each element of original sequence, to the given destination.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline fun <E : Any> EntitySequence<E, *>.forEach(action: (E) -> Unit)

Perform the given action on each element.

Link copied to clipboard
inline fun <E : Any> EntitySequence<E, *>.forEachIndexed(action: (index: Int, E) -> Unit)

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

Link copied to clipboard
inline 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.

inline 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.

Link copied to clipboard
inline 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.

inline 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.

Link copied to clipboard
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.

Link copied to clipboard

Return true if the sequence has no elements.

Link copied to clipboard

Return true if the sequence has at lease one element.

Link copied to clipboard
operator fun iterator(): Iterator<E>

Return an iterator over the elements of this sequence.

Link copied to clipboard
fun <E : Any, A : Appendable> 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.

Link copied to clipboard
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.

Link copied to clipboard
fun <E : Any> EntitySequence<E, *>.last(): E

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

inline 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.

Link copied to clipboard
fun <E : Any> EntitySequence<E, *>.lastOrNull(): E?

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

inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
@JvmName(name = "_mapColumns2")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any> EntitySequence<E, T>.mapColumns(isDistinct: Boolean = false, columnSelector: (T) -> Tuple2<ColumnDeclaring<C1>, ColumnDeclaring<C2>>): List<Tuple2<C1?, C2?>>
@JvmName(name = "_mapColumns3")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any> EntitySequence<E, T>.mapColumns(isDistinct: Boolean = false, columnSelector: (T) -> Tuple3<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>>): List<Tuple3<C1?, C2?, C3?>>
@JvmName(name = "_mapColumns4")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any> EntitySequence<E, T>.mapColumns(isDistinct: Boolean = false, columnSelector: (T) -> Tuple4<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>>): List<Tuple4<C1?, C2?, C3?, C4?>>
@JvmName(name = "_mapColumns5")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any> EntitySequence<E, T>.mapColumns(isDistinct: Boolean = false, columnSelector: (T) -> Tuple5<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>>): List<Tuple5<C1?, C2?, C3?, C4?, C5?>>
@JvmName(name = "_mapColumns6")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any> EntitySequence<E, T>.mapColumns(isDistinct: Boolean = false, columnSelector: (T) -> Tuple6<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>>): List<Tuple6<C1?, C2?, C3?, C4?, C5?, C6?>>
@JvmName(name = "_mapColumns7")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any> EntitySequence<E, T>.mapColumns(isDistinct: Boolean = false, columnSelector: (T) -> Tuple7<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>>): List<Tuple7<C1?, C2?, C3?, C4?, C5?, C6?, C7?>>
@JvmName(name = "_mapColumns8")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any> EntitySequence<E, T>.mapColumns(isDistinct: Boolean = false, columnSelector: (T) -> Tuple8<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>>): List<Tuple8<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?>>
@JvmName(name = "_mapColumns9")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any, C9 : Any> EntitySequence<E, T>.mapColumns(isDistinct: Boolean = false, columnSelector: (T) -> Tuple9<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>, ColumnDeclaring<C9>>): List<Tuple9<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?>>
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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
@JvmName(name = "_mapColumns2To")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, R : MutableCollection<in Tuple2<C1?, C2?>>> EntitySequence<E, T>.mapColumnsTo(destination: R, isDistinct: Boolean = false, columnSelector: (T) -> Tuple2<ColumnDeclaring<C1>, ColumnDeclaring<C2>>): R
@JvmName(name = "_mapColumns3To")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, R : MutableCollection<in Tuple3<C1?, C2?, C3?>>> EntitySequence<E, T>.mapColumnsTo(destination: R, isDistinct: Boolean = false, columnSelector: (T) -> Tuple3<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>>): R
@JvmName(name = "_mapColumns4To")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, R : MutableCollection<in Tuple4<C1?, C2?, C3?, C4?>>> EntitySequence<E, T>.mapColumnsTo(destination: R, isDistinct: Boolean = false, columnSelector: (T) -> Tuple4<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>>): R
@JvmName(name = "_mapColumns5To")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, R : MutableCollection<in Tuple5<C1?, C2?, C3?, C4?, C5?>>> EntitySequence<E, T>.mapColumnsTo(destination: R, isDistinct: Boolean = false, columnSelector: (T) -> Tuple5<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>>): R
@JvmName(name = "_mapColumns6To")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, R : MutableCollection<in Tuple6<C1?, C2?, C3?, C4?, C5?, C6?>>> EntitySequence<E, T>.mapColumnsTo(destination: R, isDistinct: Boolean = false, columnSelector: (T) -> Tuple6<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>>): R
@JvmName(name = "_mapColumns7To")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, R : MutableCollection<in Tuple7<C1?, C2?, C3?, C4?, C5?, C6?, C7?>>> EntitySequence<E, T>.mapColumnsTo(destination: R, isDistinct: Boolean = false, columnSelector: (T) -> Tuple7<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>>): R
@JvmName(name = "_mapColumns8To")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any, R : MutableCollection<in Tuple8<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?>>> EntitySequence<E, T>.mapColumnsTo(destination: R, isDistinct: Boolean = false, columnSelector: (T) -> Tuple8<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>>): R
@JvmName(name = "_mapColumns9To")
inline fun <E : Any, T : BaseTable<E>, C1 : Any, C2 : Any, C3 : Any, C4 : Any, C5 : Any, C6 : Any, C7 : Any, C8 : Any, C9 : Any, R : MutableCollection<in Tuple9<C1?, C2?, C3?, C4?, C5?, C6?, C7?, C8?, C9?>>> EntitySequence<E, T>.mapColumnsTo(destination: R, isDistinct: Boolean = false, columnSelector: (T) -> Tuple9<ColumnDeclaring<C1>, ColumnDeclaring<C2>, ColumnDeclaring<C3>, ColumnDeclaring<C4>, ColumnDeclaring<C5>, ColumnDeclaring<C6>, ColumnDeclaring<C7>, ColumnDeclaring<C8>, ColumnDeclaring<C9>>): R

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

Link copied to clipboard
inline 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.

Link copied to clipboard
inline fun <E : Any, R : Any> EntitySequence<E, *>.mapIndexedNotNull(transform: (index: Int, E) -> R?): List<R>

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

Link copied to clipboard
inline fun <E : Any, R : Any, C : MutableCollection<in R>> EntitySequence<E, *>.mapIndexedNotNullTo(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 only the non-null results to the given destination.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline fun <E : Any, R : Any> EntitySequence<E, *>.mapNotNull(transform: (E) -> R?): List<R>

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

Link copied to clipboard
inline fun <E : Any, R : Any, C : MutableCollection<in R>> EntitySequence<E, *>.mapNotNullTo(destination: C, transform: (E) -> R?): C

Apply the given transform function to each element in the original sequence and append only the non-null results to the given destination.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard

Return true if the sequence has no elements.

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

Return true if no elements match the given predicate.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline fun <E : Any> EntitySequence<E, *>.reduceIndexedOrNull(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.

Link copied to clipboard
inline fun <E : Any> EntitySequence<E, *>.reduceOrNull(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.

Link copied to clipboard
fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.removeIf(predicate: (T) -> ColumnDeclaring<Boolean>): Int

Remove all the elements of this sequence that satisfy the given predicate.

Link copied to clipboard
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.

inline 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.

Link copied to clipboard

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

inline 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.

Link copied to clipboard
fun <E : Any, T : BaseTable<E>> EntitySequence<E, T>.sortedBy(vararg selectors: (T) -> OrderByExpression): EntitySequence<E, T>

Return a sequence sorting elements by multiple columns, in ascending or descending order. For example, sortedBy({ it.col1.asc() }, { it.col2.desc() }).

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

Return a sequence sorting elements by a column, in ascending or descending order. For example, sortedBy { it.col.asc() }

@JvmName(name = "sortedByAscending")
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard
inline 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.

Link copied to clipboard

Returns a sequence containing first n elements.

Link copied to clipboard
fun <E : Any, C : MutableCollection<in E>> EntitySequence<E, *>.toCollection(destination: C): C

Append all elements to the given destination collection.

Link copied to clipboard

Return a HashSet containing all the elements of this sequence.

Link copied to clipboard
fun <E : Any> EntitySequence<E, *>.toList(): List<E>

Return a List containing all the elements of this sequence.

Link copied to clipboard

Return a MutableList containing all the elements of this sequence.

Link copied to clipboard

Return a MutableSet containing all the elements of this sequence.

Link copied to clipboard
fun <E : Any> EntitySequence<E, *>.toSet(): Set<E>

Return a Set containing all the elements of this sequence.

Link copied to clipboard
fun <E : Any, Comparable<E>> EntitySequence<E, *>.toSortedSet(comparator: Comparator<in E>): SortedSet<E>

Return a SortedSet containing all the elements of this sequence.

Link copied to clipboard
fun <E : Entity<E>, T : Table<E>> EntitySequence<E, T>.update(entity: E): Int

Update properties of the given entity to the database and return the affected record number.

Link copied to clipboard

Return a copy of this EntitySequence with the expression modified.

Link copied to clipboard

Return a lazy Sequence that wraps each element of the original sequence into an IndexedValue containing the index of that element and the element itself.