{"id":19900607,"url":"https://github.com/gobuffalo/buffalo-pop","last_synced_at":"2025-05-02T23:30:59.215Z","repository":{"id":34099420,"uuid":"144766902","full_name":"gobuffalo/buffalo-pop","owner":"gobuffalo","description":"A plugin to use gobuffalo/pop with buffalo","archived":false,"fork":false,"pushed_at":"2023-01-28T05:47:08.000Z","size":725,"stargazers_count":19,"open_issues_count":2,"forks_count":10,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-07T08:18:11.887Z","etag":null,"topics":["go","golang","middleware","plugin","pop"],"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/gobuffalo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"markbates","patreon":"buffalo"}},"created_at":"2018-08-14T20:04:17.000Z","updated_at":"2022-10-19T07:37:24.000Z","dependencies_parsed_at":"2023-02-15T14:31:12.202Z","dependency_job_id":null,"html_url":"https://github.com/gobuffalo/buffalo-pop","commit_stats":null,"previous_names":[],"tags_count":74,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobuffalo%2Fbuffalo-pop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobuffalo%2Fbuffalo-pop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobuffalo%2Fbuffalo-pop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gobuffalo%2Fbuffalo-pop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gobuffalo","download_url":"https://codeload.github.com/gobuffalo/buffalo-pop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252122188,"owners_count":21698304,"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","golang","middleware","plugin","pop"],"created_at":"2024-11-12T20:12:45.153Z","updated_at":"2025-05-02T23:30:58.881Z","avatar_url":"https://github.com/gobuffalo.png","language":"Go","funding_links":["https://github.com/sponsors/markbates","https://patreon.com/buffalo"],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"https://github.com/gobuffalo/buffalo/blob/main/logo.svg\" width=\"360\"\u003e\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://godoc.org/github.com/gobuffalo/buffalo-pop\"\u003e\u003cimg src=\"https://godoc.org/github.com/gobuffalo/buffalo-pop?status.svg\" alt=\"GoDoc\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://goreportcard.com/report/github.com/gobuffalo/buffalo-pop\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/gobuffalo/buffalo-pop\" alt=\"Go Report Card\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# github.com/gobuffalo/buffalo-pop\n\nThis is the home for all things that combine [Buffalo](https://github.com/gobuffalo/buffalo) and [Pop](https://github.com/gobuffalo/pop).\n\n## Installation\n\n```bash\ngo install github.com/gobuffalo/buffalo-pop/v3@latest\n```\n\nOr with SQLite 3 support:\n\n```bash\ngo get -tags sqlite -v github.com/gobuffalo/buffalo-pop/v3\n```\n\n## Transaction Middleware\n\nThe `popmw.Transaction` will wrap each request inside of a new database transaction and automatically commit, or rollback, based on whether or not an error was returned from an upstream `buffalo.Handler` or `buffalo.MiddlewareFunc`.\n\n### Usage\n\nFirst you need to add the middleware to your application giving it access to your `*pop.Connection`, typically found at `models.DB`.\n\n```go\nimport \"github.com/gobuffalo/buffalo-pop/v3/pop/popmw\"\n\nfunc App() *buffalo.App {\n  // ...\n  app.Use(popmw.Transaction(models.DB))\n  // ...\n}\n```\n\nOnce added to the middleware stack for your application you can then use this transaction in upstream middleware or handlers.\n\n```go\nfunc MyHandler(c buffalo.Context) error {\n  // Get the DB connection from the context\n  tx, ok := c.Value(\"tx\").(*pop.Connection)\n  if !ok {\n    return errors.New(\"no transaction found\")\n  }\n}\n```\n\n**WARNING: DO NOT OPEN MULTIPLE TRANSACTIONS WITHIN EACH OTHER** - doing so will cause many, many, many problems.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobuffalo%2Fbuffalo-pop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgobuffalo%2Fbuffalo-pop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgobuffalo%2Fbuffalo-pop/lists"}