MapperWriteCRUDRepo

A WriteCRUDRepo wrapper that maps between different key, value, and input types. Allows adapting a repository to work with different type systems for both reading and writing.

Parameters

to

The underlying repository to wrap

mapper

The mapper for keys and values

inputMapper

The mapper for input types

Type Parameters

FromId

The external ID type

FromRegistered

The external object type for read operations

FromInput

The external input type for write operations

ToId

The internal ID type

ToRegistered

The internal object type for read operations

ToInput

The internal input type for write operations

Constructors

Properties

Link copied to clipboard
open override val deletedObjectsIdsFlow: Flow<FromId>

Flow that emits the ID of each deleted object after a successful deleteById call.

Link copied to clipboard

Provides a mapper for converting keys between inner and outer types.

Link copied to clipboard
open override val newObjectsFlow: Flow<FromRegistered>

Flow that emits each newly created object after a successful create call.

Link copied to clipboard

Mirrors WriteCRUDRepo.deletedObjectsIdsFlow under the name onDeletedObjectsIds for consistency with KV repos naming.

Link copied to clipboard

Mirrors WriteCRUDRepo.newObjectsFlow under the name onNewObjects for consistency with KV repos naming.

Link copied to clipboard

Mirrors WriteCRUDRepo.updatedObjectsFlow under the name onUpdatedObjects for consistency with KV repos naming.

Link copied to clipboard
open override val updatedObjectsFlow: Flow<FromRegistered>

Flow that emits each updated object after a successful update call.

Link copied to clipboard

Provides a mapper for converting values between inner and outer types.

Functions

Link copied to clipboard
fun <ObjectType, IdType, InputType> WriteCRUDRepo<ObjectType, IdType, InputType>.caching(kvCache: KVCache<IdType, ObjectType>, scope: CoroutineScope, locker: SmartRWLocker = SmartRWLocker(), idGetter: (ObjectType) -> IdType): WriteCRUDCacheRepo<ObjectType, IdType, InputType>
Link copied to clipboard
@JvmName(name = "convertFromT2")
suspend fun <T1, T2> SimpleSuspendableMapper<T1, T2>.convert(from: T2): T1

Converts from of type T2 to type T1 using this suspending mapper.

@JvmName(name = "convertFromT1")
suspend fun <T1, T2> SimpleSuspendableMapper<T1, T2>.convert(from: T1): T2

Converts from of type T1 to type T2 using this suspending mapper.

Link copied to clipboard
open suspend override fun convertToT1(from: ToInput): FromInput
Link copied to clipboard
open suspend override fun convertToT2(from: FromInput): ToInput
Link copied to clipboard
open suspend override fun create(values: List<FromInput>): List<FromRegistered>

Creates new objects from the given list of input values. Successfully created objects must be emitted via newObjectsFlow.

Link copied to clipboard
Link copied to clipboard
open suspend override fun deleteById(ids: List<FromId>)

Deletes objects with the given list of IDs. Successfully deleted IDs must be emitted via deletedObjectsIdsFlow.

Link copied to clipboard

Vararg overload of WriteCRUDRepo.deleteById for convenience.

Link copied to clipboard
open suspend override fun ToId.toInnerKey(): FromId

Converts a key from the outer type to the inner type.

Link copied to clipboard
open suspend override fun ToRegistered.toInnerValue(): FromRegistered

Converts a value from the outer type to the inner type.

Link copied to clipboard
open suspend override fun FromId.toOutKey(): ToId

Converts a key from the inner type to the outer type.

Link copied to clipboard
open suspend override fun FromRegistered.toOutValue(): ToRegistered

Converts a value from the inner type to the outer type.

Link copied to clipboard
open suspend override fun update(values: List<UpdatedValuePair<FromId, FromInput>>): List<FromRegistered>

Batch-updates objects using the given list of ID-value pairs. Successfully updated objects must be emitted via updatedObjectsFlow.

open suspend override fun update(id: FromId, value: FromInput): FromRegistered?

Updates the object identified by id with the given value. Successfully updated object must be emitted via updatedObjectsFlow.

Link copied to clipboard
Link copied to clipboard
inline fun <FromKey, FromValue, FromInput, ToKey, ToValue, ToInput> WriteCRUDRepo<ToValue, ToKey, ToInput>.withMapper(noinline keyFromToTo: suspend FromKey.() -> ToKey = { this as ToKey }, noinline valueFromToTo: suspend FromValue.() -> ToValue = { this as ToValue }, noinline inputFromToTo: suspend FromInput.() -> ToInput = { this as ToInput }, noinline keyToToFrom: suspend ToKey.() -> FromKey = { this as FromKey }, noinline valueToToFrom: suspend ToValue.() -> FromValue = { this as FromValue }, noinline inputToToFrom: suspend ToInput.() -> FromInput = { this as FromInput }): WriteCRUDRepo<FromValue, FromKey, FromInput>