interface ApplicationRecord
Maps model classes to database records. Kales follows some conventions when dealing with models:
id
autoincrement primary key column<model_name>_id
column naming formatUser
-> table is users
. We don't
do any fancy pluralization for now, just naively append s
at the end, which means the table
for Hero
would be heros
, awkwardly.
abstract val id: MaybeRecordId |
val JDBI: Jdbi |
fun <T : ApplicationRecord> allRecords(): List<T>
Returns a list with all records in the table (potentially dangerous for big tables!) |
|
fun <T : ApplicationRecord> createRecord(values: Map<String, Any?>): T |
|
fun <T : ApplicationRecord> T.destroyRecord(): T |
|
fun <T : ApplicationRecord> findRecord(id: RecordId): T? fun <T : ApplicationRecord> findRecord(id: Int): T? |
|
fun <T : ApplicationRecord> T.saveRecord(): T |
|
fun <T> useJdbi(block: (Handle) -> T): T |
|
fun <T : ApplicationRecord> whereRecords(clause: Map<String, Any?>): List<T>
Returns only the records matching the provided selection criteria |