Files
postgres-json/src/main/kotlin/fr/postgresjson/connexion/ExecutableReified.kt
Fabrice Lecomte a7e66ab8b5 Clean the request process
Remove paginated
Remove Entity classes
Add Annotation for serialize object
rename selectOne/selectMultiple to execute
2023-04-06 21:03:15 +02:00

38 lines
1021 B
Kotlin

package fr.postgresjson.connexion
import com.fasterxml.jackson.core.type.TypeReference
import kotlin.jvm.Throws
/**
* Select with unnamed parameters
*/
@Throws(DataNotFoundException::class)
inline fun <reified R : Any> ExecutableRaw.execute(
sql: String,
values: List<Any?> = emptyList(),
noinline block: SelectCallback<R> = {}
): R? =
execute(sql, object : TypeReference<R>() {}, values, block)
/**
* Select with named parameters
*/
@Throws(DataNotFoundException::class)
inline fun <reified R : Any> ExecutableRaw.execute(
sql: String,
values: Map<String, Any?>,
noinline block: SelectCallback<R> = {}
): R? =
execute(sql, object : TypeReference<R>() {}, values, block)
/**
* Select with named parameters
*/
@Throws(DataNotFoundException::class)
inline fun <reified R : Any> ExecutableRaw.execute(
sql: String,
vararg values: Pair<String, Any?>,
noinline block: SelectCallback<R> = {}
): R? =
execute(sql, object : TypeReference<R>() {}, values = values, block)