English | 简体中文

api-docs / org.ktorm.schema

Package org.ktorm.schema

Database schema supports, including table and column definition, column binding, and SQL types.

Types

NameSummary

BaseTable

abstract class BaseTable<E : Any> : TypeReference<E>

Base class of Ktorm’s table objects, represents relational tables in the database.

BlobSqlType

object BlobSqlType : SqlType<ByteArray>

SqlType implementation represents blob SQL type.

BooleanSqlType

object BooleanSqlType : SqlType<Boolean>

SqlType implementation represents boolean SQL type.

BytesSqlType

object BytesSqlType : SqlType<ByteArray>

SqlType implementation represents bytes SQL type.

Column

data class Column<T : Any> : ColumnDeclaring<T>

Represents database columns.

ColumnBinding

sealed class ColumnBinding

Base class of column bindings. A column might be bound to a simple property, nested properties,
or a reference to another table.

ColumnDeclaring

interface ColumnDeclaring<T : Any>

Common interface of Column and ScalarExpression.

DateSqlType

object DateSqlType : SqlType<Date>

SqlType implementation represents date SQL type.

DecimalSqlType

object DecimalSqlType : SqlType<BigDecimal>

SqlType implementation represents decimal SQL type.

DoubleSqlType

object DoubleSqlType : SqlType<Double>

SqlType implementation represents double SQL type.

EnumSqlType

class EnumSqlType<C : Enum<C>> : SqlType<C>

SqlType implementation that saves enums as strings.

FloatSqlType

object FloatSqlType : SqlType<Float>

SqlType implementation represents float SQL type.

InstantSqlType

object InstantSqlType : SqlType<Instant>

SqlType implementation represents timestamp SQL type.

IntSqlType

object IntSqlType : SqlType<Int>

SqlType implementation represents int SQL type.

LocalDateSqlType

object LocalDateSqlType : SqlType<LocalDate>

SqlType implementation represents date SQL type.

LocalDateTimeSqlType

object LocalDateTimeSqlType : SqlType<LocalDateTime>

SqlType implementation represents datetime SQL type.

LocalTimeSqlType

object LocalTimeSqlType : SqlType<LocalTime>

SqlType implementation represents time SQL type.

LongSqlType

object LongSqlType : SqlType<Long>

SqlType implementation represents long SQL type.

MonthDaySqlType

object MonthDaySqlType : SqlType<MonthDay>

SqlType implementation used to save MonthDay instances, formating them to strings with pattern MM-dd.

NestedBinding

data class NestedBinding : ColumnBinding

Bind the column to nested properties, eg. employee.manager.department.id.

ReferenceBinding

data class ReferenceBinding : ColumnBinding

Bind the column to a reference table, equivalent to a foreign key in relational databases.
Entity sequence APIs would automatically left join all references (recursively) by default.

ShortSqlType

object ShortSqlType : SqlType<Short>

SqlType implementation represents smallint SQL type.

SqlType

abstract class SqlType<T : Any>

Abstraction of SQL data types.

Table

open class Table<E : Entity<E>> : BaseTable<E>

Base class of Ktorm’s table objects. This class extends from BaseTable, additionally providing a binding mechanism
with Entity interfaces based on functions such as bindTo, references.

TextSqlType

object TextSqlType : SqlType<String>

SqlType implementation represents text SQL type.

TimeSqlType

object TimeSqlType : SqlType<Time>

SqlType implementation represents time SQL type.

TimestampSqlType

object TimestampSqlType : SqlType<Timestamp>

SqlType implementation represents timestamp SQL type.

TypeReference

abstract class TypeReference<T>

Base class used to obtain full generic type information by subclassing.

UuidSqlType

object UuidSqlType : SqlType<UUID>

SqlType implementation represents uuid SQL type.

VarcharSqlType

object VarcharSqlType : SqlType<String>

SqlType implementation represents varchar SQL type.

YearMonthSqlType

object YearMonthSqlType : SqlType<YearMonth>

SqlType implementation used to save YearMonth instances, formating them to strings with pattern yyyy-MM.

YearSqlType

object YearSqlType : SqlType<Year>

SqlType implementation used to save Year instances as integers.

Functions

NameSummary

blob

fun BaseTable<*>.blob(name: String): Column<ByteArray>

Define a column typed of BlobSqlType.

boolean

fun BaseTable<*>.boolean(name: String): Column<Boolean>

Define a column typed of BooleanSqlType.

bytes

fun BaseTable<*>.bytes(name: String): Column<ByteArray>

Define a column typed of BytesSqlType.

date

fun BaseTable<*>.date(name: String): Column<LocalDate>

Define a column typed of LocalDateSqlType.

datetime

fun BaseTable<*>.datetime(
    name: String
): Column<LocalDateTime>

Define a column typed of LocalDateTimeSqlType.

decimal

fun BaseTable<*>.decimal(name: String): Column<BigDecimal>

Define a column typed of DecimalSqlType.

double

fun BaseTable<*>.double(name: String): Column<Double>

Define a column typed of DoubleSqlType.

enum

fun <C : Enum<C>> BaseTable<*>.enum(
    name: String,
    typeRef: TypeReference<C>
): Column<C>

fun <C : Enum<C>> BaseTable<*>.enum(name: String): Column<C>

Define a column typed of EnumSqlType.

float

fun BaseTable<*>.float(name: String): Column<Float>

Define a column typed of FloatSqlType.

int

fun BaseTable<*>.int(name: String): Column<Int>

Define a column typed of IntSqlType.

jdbcDate

fun BaseTable<*>.jdbcDate(name: String): Column<Date>

Define a column typed of DateSqlType.

jdbcTime

fun BaseTable<*>.jdbcTime(name: String): Column<Time>

Define a column typed of TimeSqlType.

jdbcTimestamp

fun BaseTable<*>.jdbcTimestamp(
    name: String
): Column<Timestamp>

Define a column typed of TimestampSqlType.

kotlinTypeOf

fun <T> kotlinTypeOf(): KType

Obtain the full kotlin generic type information of the reified type argument T,
usage: kotlinTypeOf<List<String>>().

long

fun BaseTable<*>.long(name: String): Column<Long>

Define a column typed of LongSqlType.

monthDay

fun BaseTable<*>.monthDay(name: String): Column<MonthDay>

Define a column typed of MonthDaySqlType, instances of MonthDay are saved as strings in format MM-dd.

short

fun BaseTable<*>.short(name: String): Column<Short>

Define a column typed of ShortSqlType.

text

fun BaseTable<*>.text(name: String): Column<String>

Define a column typed of TextSqlType.

time

fun BaseTable<*>.time(name: String): Column<LocalTime>

Define a column typed of LocalTimeSqlType.

timestamp

fun BaseTable<*>.timestamp(name: String): Column<Instant>

Define a column typed of InstantSqlType.

typeOf

fun <T> typeOf(): Type

Obtain the full generic type information of the reified type argument T, usage: typeOf<List<String>>().

typeRef

fun <T> typeRef(): TypeReference<T>

Create a TypeReference object which references the reified type argument T.

uuid

fun BaseTable<*>.uuid(name: String): Column<UUID>

Define a column typed of UuidSqlType.

varchar

fun BaseTable<*>.varchar(name: String): Column<String>

Define a column typed of VarcharSqlType.

year

fun BaseTable<*>.year(name: String): Column<Year>

Define a column typed of YearSqlType, instances of Year are saved as integers.

yearMonth

fun BaseTable<*>.yearMonth(name: String): Column<YearMonth>

Define a column typed of YearMonthSqlType, instances of YearMonth are saved as strings in format yyyy-MM.