api-docs / org.ktorm.database / Database / useConnection
useConnection
inline fun <T> useConnection(func: (Connection) -> T): T
(source code)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.
Parameters
func
- the executed callback function.
Return
the result of the callback function.