mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-14 21:09:24 +00:00
several updates
This commit is contained in:
@@ -1,15 +1,22 @@
|
||||
package dev.inmo.micro_utils.repos.pagination
|
||||
|
||||
import dev.inmo.micro_utils.common.toCoercedInt
|
||||
import dev.inmo.micro_utils.pagination.*
|
||||
import dev.inmo.micro_utils.pagination.utils.getAllWithNextPaging
|
||||
import dev.inmo.micro_utils.repos.ReadKeyValueRepo
|
||||
|
||||
suspend inline fun <Key, Value, REPO : ReadKeyValueRepo<Key, Value>> REPO.getAll(
|
||||
pagination: Pagination,
|
||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||
crossinline methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>
|
||||
): List<Pair<Key, Value>> = getAllWithNextPaging {
|
||||
): List<Pair<Key, Value>> = getAllWithNextPaging(pagination) {
|
||||
val result = methodCaller(it)
|
||||
result.changeResultsUnchecked(
|
||||
result.results.mapNotNull { it to (get(it) ?: return@mapNotNull null) }
|
||||
)
|
||||
}
|
||||
|
||||
suspend inline fun <Key, Value, REPO : ReadKeyValueRepo<Key, Value>> REPO.getAll(
|
||||
@Suppress("REDUNDANT_INLINE_SUSPEND_FUNCTION_TYPE")
|
||||
crossinline methodCaller: suspend REPO.(Pagination) -> PaginationResult<Key>
|
||||
): List<Pair<Key, Value>> = getAll(FirstPagePagination(count().toCoercedInt()), methodCaller)
|
||||
|
Reference in New Issue
Block a user