{"id":19404385,"url":"https://github.com/nicolasparada/go-db","last_synced_at":"2025-04-24T09:30:26.046Z","repository":{"id":79219962,"uuid":"604802392","full_name":"nicolasparada/go-db","owner":"nicolasparada","description":"Wrapper over pgx with better transaction API","archived":false,"fork":false,"pushed_at":"2025-04-14T19:09:48.000Z","size":92,"stargazers_count":5,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T13:39:25.744Z","etag":null,"topics":["go","go-module","go-package","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nicolasparada.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}},"created_at":"2023-02-21T20:26:16.000Z","updated_at":"2025-02-16T12:43:03.000Z","dependencies_parsed_at":"2023-12-18T18:30:12.399Z","dependency_job_id":"469187cc-17ad-4a79-b802-e8523354bfdc","html_url":"https://github.com/nicolasparada/go-db","commit_stats":{"total_commits":40,"total_committers":3,"mean_commits":"13.333333333333334","dds":0.35,"last_synced_commit":"72a76bd0fcfde24fe13d08af3aeaf2686b1debea"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolasparada%2Fgo-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolasparada%2Fgo-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolasparada%2Fgo-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nicolasparada%2Fgo-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nicolasparada","download_url":"https://codeload.github.com/nicolasparada/go-db/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250477828,"owners_count":21437049,"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":["go","go-module","go-package","golang"],"created_at":"2024-11-10T11:34:29.922Z","updated_at":"2025-04-24T09:30:26.023Z","avatar_url":"https://github.com/nicolasparada.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Golang Database Wrapper\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/nicolasparada/go-db.svg)](https://pkg.go.dev/github.com/nicolasparada/go-db)\n\n```bash\ngo get github.com/nicolasparada/go-db\n```\n\nSimple Golang database wrapper over [github.com/jackc/pgx/v5](https://github.com/jackc/pgx) with better transactions API.\nSpecifically designed to work with [CockroachDB](https://cockroachlabs.com).\n\nInstead of starting a transaction, commiting (or rolling back) each time,\nyou simply pass a callback function. This allows for defining methods\nover a single database object and you can either run them standalone\nor inside a transaction.\n\n```go\ntype Repo struct {\n    db *db.DB\n}\n\nfunc (repo *Repo) Insert(ctx context.Context) error {\n    repo.db.Exec(ctx, \"INSERT INTO ...\")\n}\n\nfunc (repo *Repo) Update(ctx context.Context) error {\n    repo.db.Exec(ctx, \"UPDATE ... SET ...\")\n}\n\nfunc (repo *Repo) InsertAndUpdate(ctx context.Context) error {\n    return repo.db.RunTx(ctx, func(ctx context.Context) error {\n        repo.Insert(ctx)\n        repo.Update(ctx)\n    })\n}\n```\n\n## How it works?\n\nWhen you call `RunTx` it starts a new transaction and saves that object inside context. Calls to `Query`, `QueryRow` and `Exec` will check on the context and will either use the new transaction object or take a connection directly from the pool.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolasparada%2Fgo-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnicolasparada%2Fgo-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnicolasparada%2Fgo-db/lists"}