activemodel / kales / ApplicationRecord

ApplicationRecord

interface ApplicationRecord

Maps model classes to database records. Kales follows some conventions when dealing with models:

Properties

id

abstract val id: MaybeRecordId

Companion Object Properties

JDBI

val JDBI: Jdbi

Companion Object Functions

allRecords

fun <T : ApplicationRecord> allRecords(): List<T>

Returns a list with all records in the table (potentially dangerous for big tables!)

createRecord

fun <T : ApplicationRecord> createRecord(values: Map<String, Any?>): T

destroyRecord

fun <T : ApplicationRecord> T.destroyRecord(): T

findRecord

fun <T : ApplicationRecord> findRecord(id: RecordId): T?
fun <T : ApplicationRecord> findRecord(id: Int): T?

saveRecord

fun <T : ApplicationRecord> T.saveRecord(): T

useJdbi

fun <T> useJdbi(block: (Handle) -> T): T

whereRecords

fun <T : ApplicationRecord> whereRecords(clause: Map<String, Any?>): List<T>

Returns only the records matching the provided selection criteria