Files
postgres-json/src/main/kotlin/fr/postgresjson/connexion/ExecutableRaw.kt

65 lines
2.0 KiB
Kotlin

package fr.postgresjson.connexion
import com.fasterxml.jackson.core.type.TypeReference
import com.github.jasync.sql.db.QueryResult
import kotlin.jvm.Throws
typealias SelectCallback<R> = QueryResult.(R?) -> Unit
sealed interface ExecutableRaw : Executable {
/**
* Select with [List] of parameters
*/
@Throws(DataNotFoundException::class)
fun <R : Any> execute(
sql: String,
typeReference: TypeReference<R>,
values: List<Any?> = emptyList(),
block: SelectCallback<R> = {}
): R?
/**
* Select with [Map] of parameters
*/
@Throws(DataNotFoundException::class)
fun <R : Any> execute(
sql: String,
typeReference: TypeReference<R>,
values: Map<String, Any?>,
block: SelectCallback<R> = {}
): R?
/**
* Select with multiple [Pair] of parameters
*/
@Throws(DataNotFoundException::class)
fun <R : Any> execute(
sql: String,
typeReference: TypeReference<R>,
vararg values: Pair<String, Any?>,
block: SelectCallback<R> = {}
): R? = execute(sql, typeReference, values.toMap(), block)
fun <R : Any?> exec(sql: String, value: R): QueryResult = exec(sql, listOf(value))
fun exec(sql: String, values: List<Any?>): QueryResult
fun exec(sql: String, values: Map<String, Any?>): QueryResult
fun exec(sql: String, vararg values: Pair<String, Any?>): QueryResult = exec(sql, values.toMap())
/**
* Warning: this method not use prepared statement
*/
fun <R : Any?> sendQuery(sql: String, value: R): QueryResult = sendQuery(sql, listOf(value))
/**
* Warning: this method not use prepared statement
*/
fun sendQuery(sql: String, values: List<Any?>): QueryResult
/**
* Warning: this method not use prepared statement
*/
fun sendQuery(sql: String, values: Map<String, Any?>): QueryResult
/**
* Warning: this method not use prepared statement
*/
fun sendQuery(sql: String, vararg values: Pair<String, Any?>): QueryResult = sendQuery(sql, values.toMap())
}