English | 简体中文

api-docs / me.liuwj.ktorm.schema

Package me.liuwj.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.

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 finding functions would automatically left join all references (recursively) by default.

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

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 <E : Any> BaseTable<E>.blob(
    name: String
): BaseTable.ColumnRegistration<ByteArray, E>

Define a column typed of BlobSqlType.

boolean

fun <E : Any> BaseTable<E>.boolean(
    name: String
): BaseTable.ColumnRegistration<Boolean, E>

Define a column typed of BooleanSqlType.

bytes

fun <E : Any> BaseTable<E>.bytes(
    name: String
): BaseTable.ColumnRegistration<ByteArray, E>

Define a column typed of BytesSqlType.

date

fun <E : Any> BaseTable<E>.date(
    name: String
): BaseTable.ColumnRegistration<LocalDate, E>

Define a column typed of LocalDateSqlType.

datetime

fun <E : Any> BaseTable<E>.datetime(
    name: String
): BaseTable.ColumnRegistration<LocalDateTime, E>

Define a column typed of LocalDateTimeSqlType.

decimal

fun <E : Any> BaseTable<E>.decimal(
    name: String
): BaseTable.ColumnRegistration<BigDecimal, E>

Define a column typed of DecimalSqlType.

double

fun <E : Any> BaseTable<E>.double(
    name: String
): BaseTable.ColumnRegistration<Double, E>

Define a column typed of DoubleSqlType.

float

fun <E : Any> BaseTable<E>.float(
    name: String
): BaseTable.ColumnRegistration<Float, E>

Define a column typed of FloatSqlType.

int

fun <E : Any> BaseTable<E>.int(
    name: String
): BaseTable.ColumnRegistration<Int, E>

Define a column typed of IntSqlType.

jdbcDate

fun <E : Any> BaseTable<E>.jdbcDate(
    name: String
): BaseTable.ColumnRegistration<Date, E>

Define a column typed of DateSqlType.

jdbcTime

fun <E : Any> BaseTable<E>.jdbcTime(
    name: String
): BaseTable.ColumnRegistration<Time, E>

Define a column typed of TimeSqlType.

jdbcTimestamp

fun <E : Any> BaseTable<E>.jdbcTimestamp(
    name: String
): BaseTable.ColumnRegistration<Timestamp, E>

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 <E : Any> BaseTable<E>.long(
    name: String
): BaseTable.ColumnRegistration<Long, E>

Define a column typed of LongSqlType.

monthDay

fun <E : Any> BaseTable<E>.monthDay(
    name: String
): BaseTable.ColumnRegistration<MonthDay, E>

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

text

fun <E : Any> BaseTable<E>.text(
    name: String
): BaseTable.ColumnRegistration<String, E>

Define a column typed of TextSqlType.

time

fun <E : Any> BaseTable<E>.time(
    name: String
): BaseTable.ColumnRegistration<LocalTime, E>

Define a column typed of LocalTimeSqlType.

timestamp

fun <E : Any> BaseTable<E>.timestamp(
    name: String
): BaseTable.ColumnRegistration<Instant, E>

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.

varchar

fun <E : Any> BaseTable<E>.varchar(
    name: String
): BaseTable.ColumnRegistration<String, E>

Define a column typed of VarcharSqlType.

year

fun <E : Any> BaseTable<E>.year(
    name: String
): BaseTable.ColumnRegistration<Year, E>

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

yearMonth

fun <E : Any> BaseTable<E>.yearMonth(
    name: String
): BaseTable.ColumnRegistration<YearMonth, E>

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