implement SelectOne and multiple

add Fixtures
This commit is contained in:
2019-06-04 13:28:38 +02:00
parent c5d4bfb07a
commit 81e46735df
5 changed files with 69 additions and 17 deletions

View File

@@ -26,7 +26,7 @@ class Connection(
return connection
}
inline fun <T, reified R :EntityI<T?>> execute(sql: String, values: List<Any?> = emptyList()): R? {
inline fun <T, reified R : EntityI<T?>> selectOne(sql: String, values: List<Any?> = emptyList()): R? {
val future = connect().sendPreparedStatement(sql, values)
val json = future.get().rows[0].getString(0)
if (json === null) {
@@ -37,4 +37,16 @@ class Connection(
return obj
}
}
inline fun <T, reified R : List<EntityI<T?>>> select(sql: String, values: List<Any?> = emptyList()): R {
val future = connect().sendPreparedStatement(sql, values)
val json = future.get().rows[0].getString(0)
if (json === null) {
return listOf<EntityI<T?>>() as R
} else {
val obj = serializer.deserializeList<R>(json)
return obj
}
}
}