mirror of
https://github.com/InsanusMokrassar/MicroUtils.git
synced 2024-11-22 08:13:49 +00:00
improvements in AbstractExposedCRUDRepo
This commit is contained in:
parent
f6ef5c61c5
commit
1afbf03606
@ -2,6 +2,10 @@
|
||||
|
||||
## 0.20.20
|
||||
|
||||
* `Repos`:
|
||||
* `Exposed`:
|
||||
* Add opportunity for setup flows in `AbstractExposedCRUDRepo`
|
||||
|
||||
## 0.20.19
|
||||
|
||||
* `Versions`:
|
||||
|
@ -1,14 +1,19 @@
|
||||
package dev.inmo.micro_utils.repos.exposed
|
||||
|
||||
import dev.inmo.micro_utils.repos.CRUDRepo
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
|
||||
abstract class AbstractExposedCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||
flowsChannelsSize: Int = 0,
|
||||
tableName: String = ""
|
||||
tableName: String = "",
|
||||
replyCacheInFlows: Int = 0,
|
||||
onBufferOverflowBehaviour: BufferOverflow = BufferOverflow.SUSPEND
|
||||
) :
|
||||
AbstractExposedWriteCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||
flowsChannelsSize,
|
||||
tableName
|
||||
tableName,
|
||||
replyCacheInFlows,
|
||||
onBufferOverflowBehaviour
|
||||
),
|
||||
ExposedCRUDRepo<ObjectType, IdType>,
|
||||
CRUDRepo<ObjectType, IdType, InputValueType>
|
||||
|
@ -2,6 +2,7 @@ package dev.inmo.micro_utils.repos.exposed
|
||||
|
||||
import dev.inmo.micro_utils.repos.UpdatedValuePair
|
||||
import dev.inmo.micro_utils.repos.WriteCRUDRepo
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.flow.*
|
||||
import org.jetbrains.exposed.sql.*
|
||||
import org.jetbrains.exposed.sql.statements.*
|
||||
@ -11,19 +12,26 @@ import java.util.Objects
|
||||
abstract class AbstractExposedWriteCRUDRepo<ObjectType, IdType, InputValueType>(
|
||||
flowsChannelsSize: Int = 0,
|
||||
tableName: String = "",
|
||||
replyCacheInFlows: Int = 0
|
||||
replyCacheInFlows: Int = 0,
|
||||
onBufferOverflowBehaviour: BufferOverflow = BufferOverflow.SUSPEND
|
||||
) :
|
||||
AbstractExposedReadCRUDRepo<ObjectType, IdType>(tableName),
|
||||
ExposedCRUDRepo<ObjectType, IdType>,
|
||||
WriteCRUDRepo<ObjectType, IdType, InputValueType>
|
||||
{
|
||||
protected val _newObjectsFlow = MutableSharedFlow<ObjectType>(replyCacheInFlows, flowsChannelsSize)
|
||||
protected val _updatedObjectsFlow = MutableSharedFlow<ObjectType>(replyCacheInFlows, flowsChannelsSize)
|
||||
protected val _deletedObjectsIdsFlow = MutableSharedFlow<IdType>(replyCacheInFlows, flowsChannelsSize)
|
||||
protected open val _newObjectsFlow = MutableSharedFlow<ObjectType>(replyCacheInFlows, flowsChannelsSize, onBufferOverflowBehaviour)
|
||||
protected open val _updatedObjectsFlow = MutableSharedFlow<ObjectType>(replyCacheInFlows, flowsChannelsSize, onBufferOverflowBehaviour)
|
||||
protected open val _deletedObjectsIdsFlow = MutableSharedFlow<IdType>(replyCacheInFlows, flowsChannelsSize, onBufferOverflowBehaviour)
|
||||
|
||||
override val newObjectsFlow: Flow<ObjectType> = _newObjectsFlow.asSharedFlow()
|
||||
override val updatedObjectsFlow: Flow<ObjectType> = _updatedObjectsFlow.asSharedFlow()
|
||||
override val deletedObjectsIdsFlow: Flow<IdType> = _deletedObjectsIdsFlow.asSharedFlow()
|
||||
override val newObjectsFlow: Flow<ObjectType> by lazy {
|
||||
_newObjectsFlow.asSharedFlow()
|
||||
}
|
||||
override val updatedObjectsFlow: Flow<ObjectType> by lazy {
|
||||
_updatedObjectsFlow.asSharedFlow()
|
||||
}
|
||||
override val deletedObjectsIdsFlow: Flow<IdType> by lazy {
|
||||
_deletedObjectsIdsFlow.asSharedFlow()
|
||||
}
|
||||
|
||||
protected abstract fun InsertStatement<Number>.asObject(value: InputValueType): ObjectType
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user