remove onInit()

This commit is contained in:
InsanusMokrassar 2020-10-17 18:01:22 +06:00
parent 82b39baada
commit d34c5d845a
5 changed files with 4 additions and 6 deletions

View File

@ -5,6 +5,4 @@ import org.jetbrains.exposed.sql.Database
interface ExposedRepo : Repo {
val database: Database
fun onInit()
}

View File

@ -24,7 +24,7 @@ open class ExposedKeyValueRepo<Key, Value>(
override val onNewValue: Flow<Pair<Key, Value>> = onNewValueChannel.asFlow()
override val onValueRemoved: Flow<Key> = onValueRemovedChannel.asFlow()
override fun onInit() { initTable() }
init { initTable() }
override suspend fun set(k: Key, v: Value) {
transaction(database) {

View File

@ -15,7 +15,7 @@ open class ExposedReadKeyValueRepo<Key, Value>(
protected val valueColumn: Column<Value> = valueColumnAllocator()
override val primaryKey: PrimaryKey = PrimaryKey(keyColumn, valueColumn)
override fun onInit() { initTable() }
init { initTable() }
override suspend fun get(k: Key): Value? = transaction(database) {
select { keyColumn.eq(k) }.limit(1).firstOrNull() ?.getOrNull(valueColumn)

View File

@ -27,7 +27,7 @@ open class ExposedOneToManyKeyValueRepo<Key, Value>(
override val onDataCleared: Flow<Key>
get() = _onDataCleared
override fun onInit() { initTable() }
init { initTable() }
override suspend fun add(k: Key, v: Value) {
transaction(database) {

View File

@ -14,7 +14,7 @@ open class ExposedReadOneToManyKeyValueRepo<Key, Value>(
protected val keyColumn: Column<Key> = keyColumnAllocator()
protected val valueColumn: Column<Value> = valueColumnAllocator()
override fun onInit() { initTable() }
init { initTable() }
override suspend fun count(k: Key): Long = transaction(database) { select { keyColumn.eq(k) }.count() }