Extract Reified method to Extension

Add update method
This commit is contained in:
2021-07-16 01:53:12 +02:00
parent eb3a732440
commit 69f85b5bf5
14 changed files with 357 additions and 212 deletions

View File

@@ -10,8 +10,19 @@ sealed interface EmbedExecutable {
val name: String
/* Select One */
/**
* Select One entity with list of parameters
* Update [EntityI] with one entity as argument
*/
fun <R : EntityI> update(
typeReference: TypeReference<R>,
value: R,
block: SelectOneCallback<R> = {}
): R? =
selectOne(typeReference, listOf(value), block)
/**
* Select One [EntityI] with [List] of parameters
*/
fun <R : EntityI> selectOne(
typeReference: TypeReference<R>,
@@ -19,26 +30,60 @@ sealed interface EmbedExecutable {
block: SelectOneCallback<R> = {}
): R?
/**
* Select One [EntityI] with [Map] of parameters
*/
fun <R : EntityI> selectOne(
typeReference: TypeReference<R>,
values: Map<String, Any?>,
block: SelectOneCallback<R> = {}
): R?
/**
* Select One [EntityI] with multiple [Pair] of parameters
*/
fun <R : EntityI> selectOne(
typeReference: TypeReference<R>,
vararg values: Pair<String, Any?>,
block: SelectOneCallback<R> = {}
): R? =
selectOne(typeReference, values.toMap(), block)
/* Select Multiples */
/**
* Select Multiple [EntityI] with [List] of parameters
*/
fun <R : EntityI> select(
typeReference: TypeReference<List<R>>,
values: List<Any?> = emptyList(),
block: SelectCallback<R> = {}
): List<R>
/**
* Select Multiple [EntityI] with [Map] of parameters
*/
fun <R : EntityI> select(
typeReference: TypeReference<List<R>>,
values: Map<String, Any?>,
block: SelectCallback<R> = {}
): List<R>
/**
* Select Multiple [EntityI] with multiple [Pair] of parameters
*/
fun <R : EntityI> select(
typeReference: TypeReference<List<R>>,
vararg values: Pair<String, Any?>,
block: SelectCallback<R> = {}
): List<R> =
select(typeReference, values.toMap(), block)
/* Select Paginated */
/**
* Select Paginated [EntityI] with [Map] of parameters
*/
fun <R : EntityI> select(
page: Int,
limit: Int,
@@ -47,6 +92,18 @@ sealed interface EmbedExecutable {
block: SelectPaginatedCallback<R> = {}
): Paginated<R>
/**
* Select Paginated [EntityI] with multiple [Pair] of parameters
*/
fun <R : EntityI> select(
page: Int,
limit: Int,
typeReference: TypeReference<List<R>>,
vararg values: Pair<String, Any?>,
block: SelectPaginatedCallback<R> = {}
): Paginated<R> =
select(page, limit, typeReference, values.toMap(), block)
fun exec(values: List<Any?> = emptyList()): QueryResult
fun exec(values: Map<String, Any?>): QueryResult
fun exec(vararg values: Pair<String, Any?>): QueryResult = exec(values.toMap())
@@ -57,6 +114,5 @@ sealed interface EmbedExecutable {
fun sendQuery(values: List<Any?> = emptyList()): Int
fun sendQuery(values: Map<String, Any?>): Int
fun sendQuery(vararg values: Pair<String, Any?>): Int =
sendQuery(values.toMap())
fun sendQuery(vararg values: Pair<String, Any?>): Int = sendQuery(values.toMap())
}