diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-05-05 22:36:44 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-05-05 22:36:44 +0200 |
commit | b3475b4541c60545b32ac8e04d6d099f9edf5097 (patch) | |
tree | db31ef784187e35b5133beb353aec893fba108c4 /kvision-server/src | |
parent | f9e9edd177d7ff48f0300a328c4e7bb01ffc7368 (diff) | |
download | kvision-b3475b4541c60545b32ac8e04d6d099f9edf5097.tar.gz kvision-b3475b4541c60545b32ac8e04d6d099f9edf5097.tar.bz2 kvision-b3475b4541c60545b32ac8e04d6d099f9edf5097.zip |
Kwery ORM integration.
Diffstat (limited to 'kvision-server/src')
-rw-r--r-- | kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt b/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt index 1d174f88..ad4185d6 100644 --- a/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt +++ b/kvision-server/src/main/kotlin/pl/treksoft/kvision/types/KDate.kt @@ -21,6 +21,11 @@ */ package pl.treksoft.kvision.types +import com.github.andrewoma.kwery.mapper.SimpleConverter +import com.github.andrewoma.kwery.mapper.TableConfiguration +import com.github.andrewoma.kwery.mapper.reifiedConverter +import com.github.andrewoma.kwery.mapper.standardConverters +import com.github.andrewoma.kwery.mapper.util.camelToLowerUnderscore import java.text.SimpleDateFormat import java.util.* @@ -40,3 +45,13 @@ internal actual fun KDate.toStringF(format: String) = SimpleDateFormat(format).format(this.toJava()) fun KDate.toJava(): java.util.Date = java.util.Date(this.time) + +object KDateConverter : SimpleConverter<KDate>( + { row, c -> KDate(row.date(c).time) }, + { it.toJava() } +) + +val kvTableConfig = TableConfiguration( + converters = standardConverters + reifiedConverter(KDateConverter), + namingConvention = camelToLowerUnderscore +) |