{"id":21040001,"url":"https://github.com/sawka/txwrap","last_synced_at":"2026-04-21T08:40:03.994Z","repository":{"id":65894866,"uuid":"601797060","full_name":"sawka/txwrap","owner":"sawka","description":"TxWrap implements a transaction wrapper around a *sqlx.Tx transaction that simplifies error handling, commits, and rollbacks.","archived":false,"fork":false,"pushed_at":"2024-05-13T18:35:06.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T09:55:32.889Z","etag":null,"topics":["database","golang"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/sawka/txwrap","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sawka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-14T20:55:55.000Z","updated_at":"2024-05-13T18:32:20.000Z","dependencies_parsed_at":"2024-05-13T19:45:29.293Z","dependency_job_id":null,"html_url":"https://github.com/sawka/txwrap","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawka%2Ftxwrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawka%2Ftxwrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawka%2Ftxwrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sawka%2Ftxwrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sawka","download_url":"https://codeload.github.com/sawka/txwrap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243482942,"owners_count":20297908,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","golang"],"created_at":"2024-11-19T13:44:21.258Z","updated_at":"2025-12-27T11:23:01.863Z","avatar_url":"https://github.com/sawka.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TxWrap\n\nTxWrap implements a transaction wrapper around a *sqlx.Tx transaction that simplifies error handling\nand is guaranteed to either call Commit or Rollback on all transactions it starts.\n\nTxWrap will automatically handle all database errors when using the TxWrap interface.  After an error\noccurs, all future database calls using the same TxWrap will be short-circuited and fail immediately\nand the transaction will be rolled back.\n\nUsage:\n\n```\ntxErr := WithTx(ctx, db, func(tx *txwrap.TxWrap) error {\n    query := `SELECT sessionid FROM sessions WHERE sessionid = ?`\n    if !tx.Exists(query, sessionId) {\n        query = `INSERT INTO session (sessionid, counter) VALUES (?, 0)`\n        tx.Exec(query, sessionId)\n    }\n    query = `UPDATE session SET counter = counter + 1 WHERE sessionid = ?`\n    tx.Exec(query, sessionId)\n    return nil\n})\n```\n\nNote that no error handling is necessary.  If any of the database calls (Exists, Exec) fail\nthe transaction will be automatically rolled back.  If the function completes with no errors\n(and the return value is nil) the transaction will be committed.  By returning a non-nil\nerror, you can also force a rollback at any time.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsawka%2Ftxwrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsawka%2Ftxwrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsawka%2Ftxwrap/lists"}