implement SelectOne and multiple
add Fixtures
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user