{"id":51050021,"url":"https://github.com/lukethacoder/query-builder-go","last_synced_at":"2026-06-22T16:32:27.468Z","repository":{"id":366612065,"uuid":"1276986980","full_name":"lukethacoder/query-builder-go","owner":"lukethacoder","description":"🎯 Go Query Builder implementation","archived":false,"fork":false,"pushed_at":"2026-06-22T14:57:13.000Z","size":36,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-22T16:22:28.921Z","etag":null,"topics":[],"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/lukethacoder.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-22T13:29:38.000Z","updated_at":"2026-06-22T14:58:01.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lukethacoder/query-builder-go","commit_stats":null,"previous_names":["lukethacoder/query-builder-go"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lukethacoder/query-builder-go","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukethacoder%2Fquery-builder-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukethacoder%2Fquery-builder-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukethacoder%2Fquery-builder-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukethacoder%2Fquery-builder-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lukethacoder","download_url":"https://codeload.github.com/lukethacoder/query-builder-go/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lukethacoder%2Fquery-builder-go/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34657893,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-22T02:00:06.391Z","response_time":106,"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":[],"created_at":"2026-06-22T16:32:26.801Z","updated_at":"2026-06-22T16:32:27.463Z","avatar_url":"https://github.com/lukethacoder.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# query-builder-go\n\nGo implementation of the [Query Builder specification](https://github.com/lukethacoder/query-builder-spec) — a language-neutral standard for representing, addressing, manipulating, validating, and serializing structured filter queries.\n\n[![CI](https://github.com/lukethacoder/query-builder-go/actions/workflows/ci.yml/badge.svg)](https://github.com/lukethacoder/query-builder-go/actions/workflows/ci.yml)\n\n## Installation\n\n```sh\ngo get github.com/lukethacoder/query-builder-go\n```\n\nRequires Go 1.23 or later.\n\n## Usage\n\n```go\nimport qb \"github.com/lukethacoder/query-builder-go\"\n\n// Build a query\nquery := \u0026qb.RuleGroup{\n    Combinator: \"and\",\n    Rules: []qb.AnyNode{\n        \u0026qb.Rule{Field: \"firstName\", Operator: \"beginsWith\", Value: \"Stev\"},\n        \u0026qb.RuleGroup{\n            Combinator: \"or\",\n            Not: true,\n            Rules: []qb.AnyNode{\n                \u0026qb.Rule{Field: \"age\", Operator: \"between\", Value: \"26,52\"},\n                \u0026qb.Rule{Field: \"city\", Operator: \"in\", Value: \"London,Paris,Tokyo\"},\n            },\n        },\n    },\n}\n\n// Serialize to SQL\nsql := qb.FormatSQL(query, qb.SqlExportOptions{})\n// =\u003e (firstName LIKE 'Stev%' and NOT (age between '26' and '52' or city in ('London', 'Paris', 'Tokyo')))\n\n// Parameterized SQL\nresult := qb.FormatParameterized(query, qb.ParameterizedExportOptions{})\n// result.SQL  =\u003e \"(firstName LIKE ? and NOT (age between ? and ? or city in (?, ?, ?)))\"\n// result.Params =\u003e [\"Stev%\", \"26\", \"52\", \"London\", \"Paris\", \"Tokyo\"]\n\n// Named parameters\nnamed := qb.FormatParameterizedNamed(query, qb.ParameterizedExportOptions{})\n\n// MongoDB filter document\ndoc := qb.FormatMongoDBQuery(query, qb.CommonExportOptions{})\n\n// JsonLogic rule\nlogic := qb.FormatJSONLogic(query, qb.CommonExportOptions{})\n\n// Canonical JSON\njson, _ := qb.FormatJSON(query)\njsonNoIDs, _ := qb.FormatJSONWithoutIDs(query)\n\n// Parse JSON back to a query\nparsed, _ := qb.ParseJSON(json)\n```\n\n## Manipulation\n\nAll manipulation functions are immutable — they return a new query tree and never modify the input.\n\n```go\n// Add a rule\nquery = qb.Add(query, \u0026qb.Rule{Field: \"lastName\", Operator: \"=\", Value: \"Vai\"}, qb.Path{}, qb.AddOptions{}).(qb.AnyNode)\n\n// Remove a rule by path\nquery = qb.Remove(query, qb.Path{0})\n\n// Update a property\nquery = qb.Update(query, \"combinator\", \"or\", qb.Path{}, qb.UpdateOptions{})\n\n// Move a node\nquery = qb.Move(query, qb.Path{0}, qb.Path{1}, qb.MoveOptions{})\n\n// Insert at an exact position\nquery = qb.Insert(query, newRule, qb.Path{0}, qb.InsertOptions{})\n\n// Wrap two nodes into a sub-group\nquery = qb.Group(query, qb.Path{0}, qb.Path{1}, qb.GroupOptions{})\n\n// Convert between standard and independent-combinator groups\nicQuery := qb.ConvertToIC(stdGroup, \"\")\nstdGroup = qb.ConvertFromIC(icGroup, \"and\")\n```\n\n## Validation\n\n```go\n// Default structural validator\nvm := qb.DefaultValidator(query)\nif !qb.IsNodeValid(\"root\", vm) {\n    // group is empty or has an invalid combinator\n}\n```\n\n## SQL presets\n\nPreset configurations for common databases:\n\n| Preset       | Field quoting | Param style  |\n|--------------|---------------|--------------|\n| `ansi`       | none          | `?`          |\n| `oracle`     | none          | `?`          |\n| `sqlite`     | none          | `?` (prefix in key) |\n| `mysql`      | none          | `?`          |\n| `mssql`      | `[field]`     | `@param`     |\n| `postgresql` | `\"field\"`     | `$1`, `$2`   |\n\n```go\nsql := qb.FormatSQL(query, qb.SqlExportOptions{Preset: \"postgresql\"})\n```\n\n## Conformance\n\nThis library targets **baseline export conformance** per the spec:\n\n- Core (data model, paths, manipulation, validation, canonical JSON) — chapters 01-06 + §7.2\n- Baseline exports: `sql`, `parameterized`, `parameterized_named`, `mongodb_query`, `jsonlogic`\n\n## Versioning\n\nThis project uses [Conventional Commits](https://www.conventionalcommits.org/) and [semantic-release](https://semantic-release.gitbook.io/) for automated versioning. Go module versions are published as git tags (`v1.2.3`).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukethacoder%2Fquery-builder-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flukethacoder%2Fquery-builder-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flukethacoder%2Fquery-builder-go/lists"}