TerminalReturningMethods

Interface containing terminal methods that return data

Inheritors

Functions

Link copied to clipboard
abstract fun <T> toColumn(targetType: KType, params: Map<String, Any?> = emptyMap()): DataResult<List<T>>

Fetches a list of values from the first column of all rows. Nullability of elements is determined by the KType: use toColumn<Int>() for non-null or toColumn<Int?>() for nullable elements.

Link copied to clipboard
inline fun <T> TerminalReturningMethods.toColumn(vararg params: Pair<String, Any?>): DataResult<List<T>>
inline fun <T> TerminalReturningMethods.toColumn(params: Map<String, Any?> = emptyMap()): DataResult<List<T>>
Link copied to clipboard
abstract fun <T> toField(targetType: KType, params: Map<String, Any?> = emptyMap()): DataResult<T>

Fetches a single value from the first column of the first row. Nullability is determined by the KType: use toField<Int>() for non-null or toField<Int?>() for nullable results.

Link copied to clipboard
inline fun <T> TerminalReturningMethods.toField(vararg params: Pair<String, Any?>): DataResult<T>
inline fun <T> TerminalReturningMethods.toField(params: Map<String, Any?> = emptyMap()): DataResult<T>
Link copied to clipboard
abstract fun <T> toFieldStrict(targetType: KType, params: Map<String, Any?> = emptyMap()): DataResult<T>

Fetches a single value from the first column of the first row. Always returns Failure if no rows are found, regardless of nullability. Nullability only controls whether a null value in the column is allowed: use toFieldStrict<Int>() to fail on null, or toFieldStrict<Int?>() to allow null values.

Link copied to clipboard
inline fun <T> TerminalReturningMethods.toFieldStrict(params: Map<String, Any?> = emptyMap()): DataResult<T>
Link copied to clipboard
abstract fun toList(params: Map<String, Any?> = emptyMap()): DataResult<List<Map<String, Any?>>>

Fetches a list of rows as List>.

Link copied to clipboard
Link copied to clipboard
abstract fun <T> toListOf(kType: KType, params: Map<String, Any?> = emptyMap()): DataResult<List<T>>

Maps results to a list of objects of the given type. Requires that column names/aliases in SQL (in snake_case convention) match property names in the target class (in camelCase convention) or have a @MapKey annotation with the stored column name.

Link copied to clipboard
inline fun <T : Any> TerminalReturningMethods.toListOf(vararg params: Pair<String, Any?>): DataResult<List<T>>

inline fun <T : Any> TerminalReturningMethods.toListOf(params: Map<String, Any?> = emptyMap()): DataResult<List<T>>

Convenient inline extension function for toListOf. Uses reified to automatically infer the target type.

Link copied to clipboard
abstract fun toSingle(params: Map<String, Any?> = emptyMap()): DataResult<Map<String, Any?>?>

Fetches a single row as Map?. Returns Success(null) if no rows.

Link copied to clipboard
Link copied to clipboard
abstract fun <T> toSingleOf(kType: KType, params: Map<String, Any?> = emptyMap()): DataResult<T>

Maps the result to a single object of the given type. Works on the same mapping principle as toListOf. Nullability is determined by the KType: use toSingleOf<User>() for non-null or toSingleOf<User?>() for nullable results.

Link copied to clipboard
inline fun <T> TerminalReturningMethods.toSingleOf(vararg params: Pair<String, Any?>): DataResult<T>

inline fun <T> TerminalReturningMethods.toSingleOf(params: Map<String, Any?> = emptyMap()): DataResult<T>

Convenient inline extension function for toSingleOf. Uses reified to automatically infer the target type.

Link copied to clipboard
abstract fun toSingleStrict(params: Map<String, Any?> = emptyMap()): DataResult<Map<String, Any?>>

Fetches a single row as Map. Returns Failure if no rows.

Link copied to clipboard
Link copied to clipboard
abstract fun toSql(): String

Returns the SQL string without executing the query.