Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction support #512

Open
adam-fowler opened this issue Oct 4, 2024 · 0 comments
Open

Transaction support #512

adam-fowler opened this issue Oct 4, 2024 · 0 comments
Labels
enhancement New feature or request good first issue Good for newcomers
Milestone

Comments

@adam-fowler
Copy link

Does it make sense to add support for transactions in similar manner to this

extension PostgresClient {
    func withTransaction<Value>(logger: Logger, _ process: (PostgresConnection) async throws -> Value) async throws -> Value {
        try await withConnection { connection in
            try await connection.query("BEGIN;", logger: logger)
            do {
                let value = try await process(connection)
                try await connection.query("COMMIT;", logger: logger)
                return value
            } catch {
                try await connection.query("ROLLBACK;", logger: logger)
                throw error
            }
        }
    }
}
@gwynne gwynne added the enhancement New feature or request label Oct 4, 2024
@fabianfett fabianfett removed their assignment Oct 4, 2024
@fabianfett fabianfett added the good first issue Good for newcomers label Oct 4, 2024
@fabianfett fabianfett added this to the 2.0.0 milestone Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants