mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-06-01 23:45:28 +00:00
18 lines
660 B
Kotlin
18 lines
660 B
Kotlin
package dev.inmo.micro_utils.repos.pagination
|
|
|
|
import dev.inmo.micro_utils.pagination.*
|
|
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
|
import dev.inmo.micro_utils.repos.ReadOneToManyKeyValueRepo
|
|
|
|
suspend inline fun <Key, Value, REPO : ReadOneToManyKeyValueRepo<Key, Value>> REPO.getAll(
|
|
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
|
crossinline methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>
|
|
): List<Pair<Key, List<Value>>> = getAllWithNextPaging {
|
|
val keysResult = methodCaller(it)
|
|
keysResult.changeResultsUnchecked(
|
|
keysResult.results.map { k ->
|
|
k to getAll(k)
|
|
}
|
|
)
|
|
}
|