{"id":21476854,"url":"https://github.com/phogolabs/orm","last_synced_at":"2025-07-09T16:04:09.443Z","repository":{"id":37271450,"uuid":"122489870","full_name":"phogolabs/orm","owner":"phogolabs","description":"Golang Query Executor and Database Connector","archived":false,"fork":false,"pushed_at":"2023-03-23T22:58:03.000Z","size":904,"stargazers_count":10,"open_issues_count":4,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-27T10:09:51.777Z","etag":null,"topics":["golang","migration","orm","sql"],"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/phogolabs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","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":"2018-02-22T14:31:16.000Z","updated_at":"2023-04-09T04:00:05.000Z","dependencies_parsed_at":"2024-06-19T04:00:41.562Z","dependency_job_id":"63ba910a-6c6f-4ddd-a1ef-fa11251c413a","html_url":"https://github.com/phogolabs/orm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/phogolabs/orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phogolabs%2Form","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phogolabs%2Form/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phogolabs%2Form/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phogolabs%2Form/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phogolabs","download_url":"https://codeload.github.com/phogolabs/orm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phogolabs%2Form/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264492281,"owners_count":23617025,"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":["golang","migration","orm","sql"],"created_at":"2024-11-23T11:10:40.886Z","updated_at":"2025-07-09T16:04:09.398Z","avatar_url":"https://github.com/phogolabs.png","language":"Go","readme":"# ORM\n\n[![Documentation][godoc-img]][godoc-url]\n![License][license-img]\n[![Build Status][action-img]][action-url]\n[![Coverage][codecov-img]][codecov-url]\n[![Go Report Card][report-img]][report-url]\n\nThe package facilitates execution of SQL scripts generated by\n[prana][prana-url]. Also it provides a query builder and object relation mapper.\nNote that it is in BETA. We may introduce breaking changes until we reach\nversion 1.0.\n\n[![ORM][orm-img]][orm-url]\n\n## Installation\n\n```console\n$ go get -u github.com/phogolabs/orm\n```\n\n## Getting Started\n\nLet's first import all required packages:\n\n```golang\nimport (\n  \"github.com/phogolabs/orm\"\n)\n```\n\nand then establish the connection:\n\n```golang\ngateway, err := orm.Open(\"sqlite3\", \"example.db\", orm.WithRoutine(routine.Statement))\nif err != nil {\n return err\n}\n```\n\n## SQL Migrations\n\nYou can execute the migration generated by [prana][prana-url]. For that you have\nto use either [embed][embed-url] package or [os][os-url] package.\n\n```golang\nif err := gateway.Migrate(resource); err != nil {\n\treturn err\n}\n```\n\n## SQL Queries\n\nThe package provides a way to work with embeddable SQL scripts. It understands predefined files with [SQL Scripts](https://github.com/phogolabs/prana#sql-scripts-and-commands).\n\nIt executes them as standard SQL queries. Let's define a SQL routines named `insert-user` and `select-all-users`:\n\n```\n-- name: insert-user\nINSERT INTO users (id, first_name, last_name)\nVALUES (:id, :first_name, :last_name);\n\n-- named: select-all-users\nSELECT * FROM users;\n```\n\nThen you can execute the desired script by just passing its name:\n\n```golang\nroutine := orm.Routine(\"select-all-users\")\n// execute the routine\n_, err = gateway.All(context.TODO(), routine, \u0026users)\n```\n\n```golang\nroutine := orm.Routine(\"insert-user\", \u0026user)\n// execute the routine\n_, err = gateway.Exec(context.TODO(), routine)\n```\n\nAlso you can execute raw SQL Scripts from your code:\n\n```golang\nquery := orm.Query(\"SELECT * FROM users WHERE id = ?\", 5432)\n// fetch the records as a slice of users\nrows, err := gateway.Only(context.TODO(), query, \u0026user)\n```\n\n## Example\n\nYou can check our [Getting Started Example](/example).\n\nFor more information, how you can change the default behavior you can read the\nhelp documentation by executing:\n\n## Contributing\n\nWe are open for any contributions. Just fork the\n[project](https://github.com/phogolabs/orm).\n\n*logo made by [Free Pik][logo-author-url]*\n\n[report-img]: https://goreportcard.com/badge/github.com/phogolabs/orm\n[report-url]: https://goreportcard.com/report/github.com/phogolabs/orm\n[logo-author-url]: https://www.freepik.com/free-photos-vectors/tree\n[logo-license]: http://creativecommons.org/licenses/by/3.0/\n[orm-url]: https://github.com/phogolabs/orm\n[orm-img]: media/img/logo.png\n[codecov-url]: https://codecov.io/gh/phogolabs/orm\n[codecov-img]: https://codecov.io/gh/phogolabs/orm/branch/master/graph/badge.svg\n[action-img]: https://github.com/phogolabs/orm/workflows/main/badge.svg\n[action-url]: https://github.com/phogolabs/orm/actions\n[orm-url]: https://github.com/phogolabs/orm\n[godoc-url]: https://godoc.org/github.com/phogolabs/orm\n[godoc-img]: https://godoc.org/github.com/phogolabs/orm?status.svg\n[license-img]: https://img.shields.io/badge/license-MIT-blue.svg\n[software-license-url]: LICENSE\n[embed-url]: https://golang.org/pkg/embed\n[os-url]: https://golang.org/pkg/os\n[prana-url]: https://github.com/phogolabs/prana\n[sqlx-url]: https://github.com/jmoiron/sqlx\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphogolabs%2Form","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphogolabs%2Form","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphogolabs%2Form/lists"}