English | 简体中文

api-docs / org.ktorm.dsl / associateByTo

associateByTo

inline fun <K, V, M : MutableMap<in K, in V>> Query.associateByTo(
    destination: M,
    keySelector: (row: QueryRowSet) -> K,
    valueTransform: (row: QueryRowSet) -> V
): M
(source code)

Populate and return the destination mutable map with key-value pairs, where key is provided by the keySelector
function and value is provided by the valueTransform function applied to rows of the query.

If any two rows have the same key returned by keySelector the last one gets added to the map.

Since
3.0.0