{"id":42583800,"url":"https://github.com/aliforever/go-elegant","last_synced_at":"2026-01-28T22:38:47.264Z","repository":{"id":50750638,"uuid":"520028801","full_name":"aliforever/go-elegant","owner":"aliforever","description":"An elegant Golang ORM for SQL","archived":false,"fork":false,"pushed_at":"2022-11-25T15:22:44.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-06-21T13:10:34.700Z","etag":null,"topics":["database","go","golang","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aliforever.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-01T08:35:56.000Z","updated_at":"2022-08-14T21:08:23.000Z","dependencies_parsed_at":"2022-09-05T02:50:38.597Z","dependency_job_id":null,"html_url":"https://github.com/aliforever/go-elegant","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/aliforever/go-elegant","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-elegant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-elegant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-elegant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-elegant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aliforever","download_url":"https://codeload.github.com/aliforever/go-elegant/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aliforever%2Fgo-elegant/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28853739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["database","go","golang","orm","sql"],"created_at":"2026-01-28T22:38:43.918Z","updated_at":"2026-01-28T22:38:47.258Z","avatar_url":"https://github.com/aliforever.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elegant\nWorking with SQL made easier\n\n## Install\n```go get github.com/aliforever/go-elegant```\n\n## Use:\n\n- Initialize db connection:\n```go\ndb, err := sql.Open(\"postgres\", \"user=postgres password=root sslmode=disable database=testapp\")\nif err != nil {\npanic(err)\n}\n```\n\n- Define your model\n```go\ntype users struct {\n\tId        int64  `json:\"id\"`\n\tFirstName string `json:\"first_name\"`\n\tLastName  string `json:\"last_name\"`\n}\n\nfunc (users) TableName() string {\n\treturn \"users\"\n}\n```\n\n- Create the instance for User (users table):\n```go\ntbl := Table[users](db)\n```\n\n- If you want to pass default options for the table, pass it as the second argument:\n\n    As an example, to always ignore `id` field when inserting data (when Id is of type autoincrement):\n```go\ntbl := Table[users](db, options.Table().SetInsertOptions(options.Insert().IgnoreFields(\"id\")))\n```\n\n- Drop the table:\n```go\nerr := tbl.DropTable()\nif err != nil {\n\tpanic(err)\n}\n```\n\n- Create the table:\n```go\nerr := tbl.BuildSchema().\n    AddColumn(columns.NewInteger(\"id\").PrimaryKey().Identity()).\n    AddColumn(columns.NewVarchar(\"first_name\", 20).NotNull()).\n    AddColumn(columns.NewVarchar(\"last_name\", 20).NotNull()).\n    Build()\nif err != nil {\n    panic(err)\n}\n```\n\n- Insert data to the table:\n```go\nerr = tbl.Insert(users{\n    FirstName: \"Ali\",\n    LastName:  \"Error\",\n}, options.Insert().IgnoreFields(\"id\"))\nif err != nil {\n    panic(err)\n}\n```\n- Read one row from the table:\n```go\ndata, err := tbl.Query(func(builder *Builder) {\n    builder.Where(\"first_name\", \"=\", \"Ali\")\n}).FindOne()\nif err != nil {\n    panic(err)\n}\nfmt.Println(data)\n```\n\n- Read all rows from the table:\n```go\nall, err := tbl.Query(nil).Find()\nif err != nil {\n    panic(err)\n}\nfmt.Println(all)\n```\n\n## TODO:\n- Implement OrderBy, GroupBy, Having\n- Implement Delete, Update","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliforever%2Fgo-elegant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faliforever%2Fgo-elegant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faliforever%2Fgo-elegant/lists"}