mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2025-09-15 13:29:38 +00:00
getAll
This commit is contained in:
@@ -45,5 +45,9 @@ abstract class AbstractExposedReadCRUDRepo<ObjectType, IdType>(
|
||||
select { selectById(id) }.limit(1).any()
|
||||
}
|
||||
|
||||
override suspend fun getAll(): Map<IdType, ObjectType> = transaction(database) {
|
||||
selectAll().associate { it.asId to it.asObject }
|
||||
}
|
||||
|
||||
override suspend fun count(): Long = transaction(db = database) { selectAll().count() }
|
||||
}
|
||||
|
@@ -5,7 +5,6 @@ import dev.inmo.micro_utils.repos.ReadKeyValueRepo
|
||||
import dev.inmo.micro_utils.repos.exposed.*
|
||||
import dev.inmo.micro_utils.repos.exposed.utils.selectPaginated
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq
|
||||
import org.jetbrains.exposed.sql.transactions.transaction
|
||||
|
||||
abstract class AbstractExposedReadKeyValueRepo<Key, Value>(
|
||||
@@ -32,6 +31,8 @@ abstract class AbstractExposedReadKeyValueRepo<Key, Value>(
|
||||
select { selectById(key) }.limit(1).any()
|
||||
}
|
||||
|
||||
override suspend fun getAll(): Map<Key, Value> = transaction(database) { selectAll().associate { it.asKey to it.asObject } }
|
||||
|
||||
override suspend fun count(): Long = transaction(database) { selectAll().count() }
|
||||
|
||||
override suspend fun keys(pagination: Pagination, reversed: Boolean): PaginationResult<Key> = transaction(database) {
|
||||
|
Reference in New Issue
Block a user