Database

class Database(connection: Connection, dbType: SQLTypeTranslator) : Closeable

This is the entrypoint of the library.

Parameters

connection

Connection of the existing database.

dbType

Constructors

Link copied to clipboard
fun Database(connection: Connection, dbType: SQLTypeTranslator)

Creates an instance of an existing database connection.

Types

Link copied to clipboard
object Companion
Link copied to clipboard
class Query(clazz: KClass<*>)

Functions

Link copied to clipboard
fun add(value: Any): Boolean

Adds a new entry.

Link copied to clipboard
inline fun <T> avg(prop: KProperty<*>, noinline block: Database.Query.() -> List<Database.Query.Clause> = { emptyList() }): Double
fun avg(clazz: KClass<*>, prop: KProperty<*>, block: Database.Query.() -> List<Database.Query.Clause> = { emptyList() }): Double

Returns the average value of the fields matching the specified criteria.

Link copied to clipboard
open override fun close()
Link copied to clipboard
inline operator fun <T> contains(value: T): Boolean
fun contains(clazz: KClass<*>, value: Any?): Boolean
Link copied to clipboard
inline fun <T> count(noinline block: Database.Query.() -> List<Database.Query.Clause> = { emptyList() }): Int
fun count(clazz: KClass<*>, block: Database.Query.() -> List<Database.Query.Clause> = { emptyList() }): Int

Counts the entries matching the specified criteria.

Link copied to clipboard
inline fun <T> createTable()

Create a new table from the definition of the data class.s

fun createTable(clazz: KClass<*>)

Create a new table from the definition of the data class.

Link copied to clipboard
inline operator fun <T> get(id: Any): T
operator fun get(clazz: KClass<*>, id: Any): Any

Get an entry by the data class and id.

Link copied to clipboard
fun makeCurrent(): Database

Make this database current on the companion object.

Link copied to clipboard
operator fun minusAssign(value: Any)
Link copied to clipboard
operator fun plusAssign(value: Any)
Link copied to clipboard
inline fun <T> query(noinline block: Database.Query.() -> List<Database.Query.Clause> = { emptyList() }): List<T>
fun query(clazz: KClass<*>, block: Database.Query.() -> List<Database.Query.Clause> = { emptyList() }): List<Any>

Query for entries matching the specified criteria.

Link copied to clipboard
fun remove(value: Any): Boolean

Delete an entry.

Link copied to clipboard
fun set(value: Any): Boolean

Adds the entry if it does not already exist or modifies it. Try to use add and update directly to reduce overhead.

Link copied to clipboard
inline fun <T> sum(prop: KProperty<*>, noinline block: Database.Query.() -> List<Database.Query.Clause> = { emptyList() }): Double
fun sum(clazz: KClass<*>, prop: KProperty<*>, block: Database.Query.() -> List<Database.Query.Clause> = { emptyList() }): Double

Sums up the fields matching the specified criteria.

Link copied to clipboard
fun update(value: Any): Boolean

Updates an existing entry.

Properties

Link copied to clipboard
val connection: Connection
Link copied to clipboard
val dbType: SQLTypeTranslator