useConnection

inline fun <T> useConnection(func: (Connection) -> T): T(source)

Obtain a connection and invoke the callback function with it.

If the current thread has opened a transaction, then this transaction's connection will be used. Otherwise, Ktorm will pass a new-created connection to the function and auto close it after it's not useful anymore.

Return

the result of the callback function.

Parameters

func

the executed callback function.