# MapperWriteCRUDRepo

open class MapperWriteCRUDRepo < FromId , FromRegistered , FromInput , ToId , ToRegistered , ToInput >(to: WriteCRUDRepo < ToRegistered , ToId , ToInput >, mapper: MapperRepo < FromId , FromRegistered , ToId , ToRegistered >, inputMapper: SimpleSuspendableMapper < FromInput , ToInput >) : WriteCRUDRepo < FromRegistered , FromId , FromInput > , MapperRepo < FromId , FromRegistered , ToId , ToRegistered > , SimpleSuspendableMapper < FromInput , ToInput > (source)

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

MapperWriteCRUDRepo
Link copied to clipboard
constructor(to: WriteCRUDRepo < ToRegistered , ToId , ToInput >, mapper: MapperRepo < FromId , FromRegistered , ToId , ToRegistered >, inputMapper: SimpleSuspendableMapper < FromInput , ToInput >)

## Properties

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

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

keyMapper
Link copied to clipboard
open override val keyMapper : SimpleSuspendableMapper < FromId , ToId >

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

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

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

onDeletedObjectsIds
Link copied to clipboard
val < IdType > WriteCRUDRepo <*, IdType , *>. onDeletedObjectsIds : Flow< IdType >

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

onNewObjects
Link copied to clipboard
val < ObjectType > WriteCRUDRepo < ObjectType , *, *>. onNewObjects : Flow< ObjectType >

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

onUpdatedObjects
Link copied to clipboard
val < ObjectType > WriteCRUDRepo < ObjectType , *, *>. onUpdatedObjects : Flow< ObjectType >

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

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

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

valueMapper
Link copied to clipboard
open override val valueMapper : SimpleSuspendableMapper < FromRegistered , ToRegistered >

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

## Functions

caching
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 >
convert
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.

convertToT1
Link copied to clipboard
open suspend override fun convertToT1 (from: ToInput ): FromInput
convertToT2
Link copied to clipboard
open suspend override fun convertToT2 (from: FromInput ): ToInput
create
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.

create
Link copied to clipboard
suspend fun < ObjectType , IdType , InputValueType > WriteCRUDRepo < ObjectType , IdType , InputValueType >. create (vararg values: InputValueType ): List < ObjectType >

Vararg overload of WriteCRUDRepo.create for convenience.

deleteById
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.

deleteById
Link copied to clipboard
suspend fun < ObjectType , IdType , InputValueType > WriteCRUDRepo < ObjectType , IdType , InputValueType >. deleteById (vararg ids: IdType )

Vararg overload of WriteCRUDRepo.deleteById for convenience.

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

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

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

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

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

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

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

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

update
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.

update
Link copied to clipboard
suspend fun < ObjectType , IdType , InputValueType > WriteCRUDRepo < ObjectType , IdType , InputValueType >. update (vararg values: UpdatedValuePair < IdType , InputValueType >): List < ObjectType >

Vararg overload of WriteCRUDRepo.update for convenience.

withMapper
Link copied to clipboard
inline fun < FromKey , FromValue , FromInput , ToKey , ToValue , ToInput > WriteCRUDRepo < ToValue , ToKey , ToInput >. withMapper (mapper: MapperRepo < FromKey , FromValue , ToKey , ToValue >, simpleSuspendableMapper: SimpleSuspendableMapper < FromInput , ToInput >): WriteCRUDRepo < FromValue , FromKey , FromInput >
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 >