Back to Exposed

execQuery

docs/api/exposed-r2dbc/org.jetbrains.exposed.v1.r2dbc/-r2dbc-transaction/exec-query.html

1.2.02.3 KB
Original Source

execQuery

suspend fun <R> execQuery(query: SuspendExecutable<ResultApi, *>, body: suspend Statement<ResultApi>.(R2dbcResult) -> R): R?

Executes the provided query object, retrieves the generated result wrapped as a R2dbcResult, then calls the specified function body with this generated value as its argument and returns its result.

This function also updates its calling R2dbcTransaction instance's statement count and overall duration, as well as whether the execution time for query exceeds the threshold set by DatabaseConfig.warnLongQueriesDuration. If Transaction.debug is set to true, these tracked values are stored for each call in Transaction.statementStats.

kotlin
val allCompleteTasks = Tasks.selectAll().where { Tasks.isComplete eq true }val completeTitles = execQuery(allCompleteTasks) { it.mapRows { row -> row.origin.get("title") } .mapNotNull(Any?::toString) .toList()}

Content copied to clipboard

Return

The result of calling body on the R2dbcResult generated by the query execution, or null if no result was returned by the database.

Parameters

query

An executable statement that is expected to potentially returns results. This includes instances of the Query class as well as executables defined using explain or any of the extension functions like insertReturning or updateReturning.

Generated by Dokka © 2026 Copyright