{"id":25268217,"url":"https://github.com/crhntr/transaction","last_synced_at":"2026-05-02T03:31:42.976Z","repository":{"id":276428716,"uuid":"929266420","full_name":"crhntr/transaction","owner":"crhntr","description":"A ready to go transaction manager","archived":false,"fork":false,"pushed_at":"2026-03-03T20:54:59.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-24T08:42:32.986Z","etag":null,"topics":["go","pgx","postgresql","sqlc","transaction"],"latest_commit_sha":null,"homepage":"","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/crhntr.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-02-08T06:19:27.000Z","updated_at":"2026-03-03T20:54:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"5b9208c7-6ee9-44f9-b732-c9b69dd4124b","html_url":"https://github.com/crhntr/transaction","commit_stats":null,"previous_names":["crhntr/transaction"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/crhntr/transaction","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crhntr%2Ftransaction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crhntr%2Ftransaction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crhntr%2Ftransaction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crhntr%2Ftransaction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crhntr","download_url":"https://codeload.github.com/crhntr/transaction/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crhntr%2Ftransaction/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32522245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","pgx","postgresql","sqlc","transaction"],"created_at":"2025-02-12T10:24:20.197Z","updated_at":"2026-05-02T03:31:42.968Z","avatar_url":"https://github.com/crhntr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Transaction Manager Utility\n\nThis package lets you do stuff like this [(full example here)](https://github.com/crhntr/muxt-example-htmx-sortable/blob/main/internal/database/tx.go):\n\n```go\npackage database\n\nimport (\n\t\"context\"\n\n\t\"github.com/jackc/pgx/v5\"\n\n\t\"github.com/crhntr/transaction\"\n)\n\n\ntype Caller interface {\n\tCall(ctx context.Context, options pgx.TxOptions, p transaction.Func) error\n}\n\ntype Transactions struct {\n\tmanager Caller\n}\n\nfunc NewTransactions(conn transaction.Beginner) *Transactions {\n\treturn NewTransactionsWithCaller(transaction.NewManager(conn))\n}\n\nfunc NewTransactionsWithCaller(m Caller) *Transactions {\n\treturn \u0026Transactions{manager: m}\n}\n\nfunc (t Transactions) ReadOnly(ctx context.Context, f ReadOnlyFunc) error {\n\to := pgx.TxOptions{AccessMode: pgx.ReadOnly}\n\treturn t.manager.Call(ctx, o, f.Func)\n}\n\nfunc (t Transactions) UpdatePriorityList(ctx context.Context, f TaskPriorityUpdateFunc) error {\n\to := pgx.TxOptions{AccessMode: pgx.ReadWrite, DeferrableMode: pgx.Deferrable}\n\treturn t.manager.Call(ctx, o, f.Func)\n}\n\ntype ReadOnlyFunc func(ReadOnlyQuerier) error\n\nfunc (f ReadOnlyFunc) Func(_ context.Context, tx pgx.Tx) error { return f(New(tx)) }\n\ntype TaskPriorityUpdateFunc func(TaskPriorityUpdater) error\n\nfunc (f TaskPriorityUpdateFunc) Func(ctx context.Context, tx pgx.Tx) error {\n\tconst statement = `SET CONSTRAINTS unique_list_priority DEFERRED;`\n\tif _, err := tx.Exec(ctx, statement); err != nil {\n\t\treturn err\n\t}\n\treturn f(New(tx))\n}\n\ntype ReadOnlyQuerier interface {\n\tListByID(ctx context.Context, id int32) (List, error)\n\tLists(ctx context.Context) ([]List, error)\n\tTasksByListID(ctx context.Context, id int32) ([]TasksByListIDRow, error)\n}\n\ntype TaskPriorityUpdater interface {\n\tListByID(ctx context.Context, id int32) (List, error)\n\tSetTaskPriority(ctx context.Context, arg SetTaskPriorityParams) error\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrhntr%2Ftransaction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrhntr%2Ftransaction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrhntr%2Ftransaction/lists"}