{"id":24319524,"url":"https://github.com/ryym/goq","last_synced_at":"2025-08-01T19:10:10.331Z","repository":{"id":57519273,"uuid":"116689583","full_name":"ryym/goq","owner":"ryym","description":"Yet another SQL builder and ORM mapper in Go","archived":false,"fork":false,"pushed_at":"2020-03-29T06:10:19.000Z","size":5807,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T20:44:40.011Z","etag":null,"topics":["go","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/ryym.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}},"created_at":"2018-01-08T14:51:31.000Z","updated_at":"2020-03-29T06:09:52.000Z","dependencies_parsed_at":"2022-09-06T05:11:05.795Z","dependency_job_id":null,"html_url":"https://github.com/ryym/goq","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ryym/goq","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryym%2Fgoq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryym%2Fgoq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryym%2Fgoq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryym%2Fgoq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryym","download_url":"https://codeload.github.com/ryym/goq/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryym%2Fgoq/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268281875,"owners_count":24225160,"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","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"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","orm","sql"],"created_at":"2025-01-17T15:33:39.336Z","updated_at":"2025-08-01T19:10:10.301Z","avatar_url":"https://github.com/ryym.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"🌱 Beta version\n\n# Goq  \n\n[![circleci](https://circleci.com/gh/ryym/goq.svg?style=svg)](https://circleci.com/gh/ryym/goq)\n[![appveyor](https://ci.appveyor.com/api/projects/status/5yf0rg3n810cnkih?svg=true)](https://ci.appveyor.com/project/ryym/goq)\n\nSQL-based DB access library for Gophers\n\n## Features\n\n### SQL-based API\n\nGoq provides the low-level API which just wraps SQL clauses as Go methods,\nInstead of abstracting a way of query construction as an opinionated API like typical frameworks.\nThat is, you already know most of the Goq API if you know SQL.\n\n### Flexible Result Mapping\n\nUsing Goq, you can collect result rows fetched from DB into various format structures:\na slice of your model, single map, map of slices, combination of them, etc.\n\n### Custom Query Builder Generation\n\nGoq can generate your custom query builder by [`go generate`](https://blog.golang.org/generate)\nbased on your models mapped to DB tables.\nThis helps you write a query with more type safety and readability.\n\n## What does it look like?\n\n```go\nimport (\n    \"fmt\"\n\n    _ \"github.com/lib/pq\"\n    \"github.com/ryym/goq\"\n)\n\nfunc main() {\n    // Connect to DB.\n    db, err := goq.Open(\"postgres\", conn)\n    panicIf(err)\n    defer db.Close()\n\n    // Initialize your builder.\n    q := NewBuilder(db.Dialect())\n\n    // Write a query.\n    query := q.Select(\n        q.Countries.ID,\n        q.Countries.Name,\n        q.Cities.All(),\n    ).From(\n        q.Countries,\n    ).Joins(\n        q.InnerJoin(q.Cities).On(\n            q.Cities.CountryID.Eq(q.Countries.ID),\n        ),\n    ).Where(\n        q.Countries.Population.Lte(500000),\n        q.Cities.Name.Like(\"New%\"),\n    ).OrderBy(\n        q.Countries.Name,\n        q.Cities.Name,\n    )\n\n    var countries []Country\n    var citiesByCountry map[int][]City\n\n    // Collect results.\n    err = db.Query(query).Collect(\n        q.Countries.ToUniqSlice(\u0026countries),\n        q.Cities.ToSliceMap(\u0026citiesByCountry).By(q.Countries.ID),\n    )\n    panicIf(err)\n\n    fmt.Println(\"Complete!\", countries, citiesByCountry)\n}\n```\n\n## Out of Scope Features\n\nGoq is not a DB management framework so does not support any of these:\n\n- schema migration\n- schema generation from Go code\n- model generation from schema\n\n## Resources\n\n- [Getting Started](https://github.com/ryym/goq/wiki/Getting-Started)\n- [API document (GoDoc)](https://godoc.org/github.com/ryym/goq)\n- [Sample application](https://github.com/ryym/goq-bookmark)\n\n## Inspiration\n\nGoq is inspired by [ScalikeJDBC](http://scalikejdbc.org/)\nwhich is a Scala library providing SQL-based API.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryym%2Fgoq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryym%2Fgoq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryym%2Fgoq/lists"}