Implement begining of migration

Move Function/Query definition
This commit is contained in:
2019-06-28 15:52:05 +02:00
parent bfefcac88d
commit ebc1a67420
18 changed files with 378 additions and 78 deletions

View File

@@ -1,6 +1,7 @@
package fr.postgresjson.connexion
import com.fasterxml.jackson.core.type.TypeReference
import com.github.jasync.sql.db.Connection
import com.github.jasync.sql.db.QueryResult
import com.github.jasync.sql.db.pool.ConnectionPool
import com.github.jasync.sql.db.postgresql.PostgreSQLConnection
@@ -28,6 +29,8 @@ class Connection(
return connection
}
fun <A> inTransaction(f: (Connection) -> CompletableFuture<A>) = connect().inTransaction(f)
fun <T, R : EntityI<T?>?> selectOne(sql: String, typeReference: TypeReference<R>, values: List<Any?> = emptyList()): R? {
val future = connect().sendPreparedStatement(sql, compileArgs(values))
val json = future.get().rows[0].getString(0)