toSingleOf

abstract fun <T> toSingleOf(kType: KType, params: Map<String, Any?> = emptyMap()): DataResult<T>

Maps the result to a single object of the given type. Works on the same mapping principle as toListOf. Nullability is determined by the KType: use toSingleOf<User>() for non-null or toSingleOf<User?>() for nullable results.


abstract fun <T> toSingleOf(kType: KType, params: Map<String, Any?> = emptyMap(), mapper: DataMapper<T & Any>): DataResult<T>

Maps the result to a single object using the provided mapper. Nullability is determined by the KType: use toSingleOf<User>(mapper) for non-null or toSingleOf<User?>(mapper) for nullable results. This bypasses reflection and is the most efficient way to map results to domain objects.