useConnection

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

Deprecated

ktorm-global will be removed in the future, please migrate to the standard API.

Obtain a connection from Database.Companion.global 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.

See also