Skip to content

Instance Method

withConnection(isolation:_:)

Lease a connection for the provided closure’s lifetime.
func withConnection<Result>(isolation: isolated (any Actor)? = #isolation, _ closure: nonisolated(nonsending) (PostgresConnection) async throws -> sending Result) async throws -> sending Result

Parameters

isolation

The actor isolation to use for the connection lease.

closure

A closure that uses the passed PostgresConnection. The closure must not capture the provided PostgresConnection.

Return Value

The closure’s return value.