toDataObject

inline fun <T : Any> Map<String, Any?>.toDataObject(): T

Converts a map (typically a database row) to a data class instance.

This is the preferred, type-safe way to convert query results to domain objects. Uses the reified type parameter to automatically infer the target class.

Naming convention: Keys in snake_case are automatically matched to camelCase properties. Use @MapKey annotation to override the default mapping.

Return

New instance of T with values from the map.

Parameters

T

Target data class type.

See also

Throws

if required properties are missing or types don't match.


fun <T : Any> Map<String, Any?>.toDataObject(kClass: KClass<T>): T