{"id":13413667,"url":"https://github.com/uptrace/bun","last_synced_at":"2025-05-13T17:04:14.965Z","repository":{"id":37012247,"uuid":"363910063","full_name":"uptrace/bun","owner":"uptrace","description":"SQL-first Golang ORM","archived":false,"fork":false,"pushed_at":"2025-05-06T07:43:20.000Z","size":3332,"stargazers_count":4152,"open_issues_count":16,"forks_count":247,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-05-06T16:17:11.605Z","etag":null,"topics":["database","go","golang","mssql","mysql","oracle","orm","postgresql","sql","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"https://bun.uptrace.dev","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uptrace.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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},"funding":{"custom":["https://uptrace.dev/sponsor"]}},"created_at":"2021-05-03T11:40:52.000Z","updated_at":"2025-05-06T11:13:17.000Z","dependencies_parsed_at":"2023-02-19T11:50:16.024Z","dependency_job_id":"f0d90286-fb5e-4ba4-9ebb-dedcbf5567a7","html_url":"https://github.com/uptrace/bun","commit_stats":{"total_commits":864,"total_committers":107,"mean_commits":8.074766355140186,"dds":"0.29282407407407407","last_synced_commit":"014b142c4ec4a0266fc7d82d1f4f765261246586"},"previous_names":[],"tags_count":1050,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptrace%2Fbun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptrace%2Fbun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptrace%2Fbun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uptrace%2Fbun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uptrace","download_url":"https://codeload.github.com/uptrace/bun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253990456,"owners_count":21995773,"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":["database","go","golang","mssql","mysql","oracle","orm","postgresql","sql","sqlite","sqlite3"],"created_at":"2024-07-30T20:01:45.873Z","updated_at":"2025-05-13T17:04:14.938Z","avatar_url":"https://github.com/uptrace.png","language":"Go","funding_links":["https://uptrace.dev/sponsor"],"categories":["Go","开源类库","ORM","ORM库"],"sub_categories":["数据库","HTTP Clients","HTTP客户端","交互工具"],"readme":"# SQL-first Golang ORM for PostgreSQL, MySQL, MSSQL, SQLite and Oracle\n\n[![build workflow](https://github.com/uptrace/bun/actions/workflows/build.yml/badge.svg)](https://github.com/uptrace/bun/actions)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/uptrace/bun)](https://pkg.go.dev/github.com/uptrace/bun)\n[![Documentation](https://img.shields.io/badge/bun-documentation-informational)](https://bun.uptrace.dev/)\n[![Chat](https://discordapp.com/api/guilds/752070105847955518/widget.png)](https://discord.gg/rWtp5Aj)\n[![Gurubase](https://img.shields.io/badge/Gurubase-Ask%20Bun%20Guru-006BFF)](https://gurubase.io/g/bun)\n\n\u003e Bun is brought to you by :star: [**uptrace/uptrace**](https://github.com/uptrace/uptrace). Uptrace\n\u003e is an open-source APM tool that supports distributed tracing, metrics, and logs. You can use it to\n\u003e monitor applications and set up automatic alerts to receive notifications via email, Slack,\n\u003e Telegram, and others.\n\u003e\n\u003e See [OpenTelemetry](example/opentelemetry) example which demonstrates how you can use Uptrace to\n\u003e monitor Bun.\n\n## Features\n\n- Works with [PostgreSQL](https://bun.uptrace.dev/guide/drivers.html#postgresql),\n  [MySQL](https://bun.uptrace.dev/guide/drivers.html#mysql) (including MariaDB),\n  [MSSQL](https://bun.uptrace.dev/guide/drivers.html#mssql),\n  [SQLite](https://bun.uptrace.dev/guide/drivers.html#sqlite).\n  [Oracle](https://bun.uptrace.dev/guide/drivers.html#oracle).\n- [ORM-like](/example/basic/) experience using good old SQL. Bun supports structs, map, scalars, and\n  slices of map/structs/scalars.\n- [Bulk inserts](https://bun.uptrace.dev/guide/query-insert.html).\n- [Bulk updates](https://bun.uptrace.dev/guide/query-update.html) using common table expressions.\n- [Bulk deletes](https://bun.uptrace.dev/guide/query-delete.html).\n- [Fixtures](https://bun.uptrace.dev/guide/fixtures.html).\n- [Migrations](https://bun.uptrace.dev/guide/migrations.html).\n- [Soft deletes](https://bun.uptrace.dev/guide/soft-deletes.html).\n\n### Resources\n\n- [**Get started**](https://bun.uptrace.dev/guide/golang-orm.html)\n- [Examples](https://github.com/uptrace/bun/tree/master/example)\n- [Discussions](https://github.com/uptrace/bun/discussions)\n- [Chat](https://discord.gg/rWtp5Aj)\n- [Reference](https://pkg.go.dev/github.com/uptrace/bun)\n- [Starter kit](https://github.com/go-bun/bun-starter-kit)\n\n### Tutorials\n\nWrote a tutorial for Bun? Create a PR to add here and on [Bun](https://bun.uptrace.dev/) site.\n\n### Featured projects using Bun\n\n- [uptrace](https://github.com/uptrace/uptrace) - Distributed tracing and metrics.\n- [paralus](https://github.com/paralus/paralus) - All-in-one Kubernetes access manager.\n- [inovex/scrumlr.io](https://github.com/inovex/scrumlr.io) - Webapp for collaborative online\n  retrospectives.\n- [gotosocial](https://github.com/superseriousbusiness/gotosocial) - Golang fediverse server.\n- [lorawan-stack](https://github.com/TheThingsNetwork/lorawan-stack) - The Things Stack, an Open\n  Source LoRaWAN Network Server.\n- [anti-phishing-bot](https://github.com/Benricheson101/anti-phishing-bot) - Discord bot for\n  deleting Steam/Discord phishing links.\n- [emerald-web3-gateway](https://github.com/oasisprotocol/emerald-web3-gateway) - Web3 Gateway for\n  the Oasis Emerald paratime.\n- [lndhub.go](https://github.com/getAlby/lndhub.go) - accounting wrapper for the Lightning Network.\n- [penguin-statistics](https://github.com/penguin-statistics/backend-next) - Penguin Statistics v3\n  Backend.\n- And\n  [hundreds more](https://github.com/uptrace/bun/network/dependents?package_id=UGFja2FnZS0yMjkxOTc4OTA4).\n\n## Why another database client?\n\nSo you can elegantly write complex queries:\n\n```go\nregionalSales := db.NewSelect().\n\tColumnExpr(\"region\").\n\tColumnExpr(\"SUM(amount) AS total_sales\").\n\tTableExpr(\"orders\").\n\tGroupExpr(\"region\")\n\ntopRegions := db.NewSelect().\n\tColumnExpr(\"region\").\n\tTableExpr(\"regional_sales\").\n\tWhere(\"total_sales \u003e (SELECT SUM(total_sales) / 10 FROM regional_sales)\")\n\nvar items []map[string]interface{}\nerr := db.NewSelect().\n\tWith(\"regional_sales\", regionalSales).\n\tWith(\"top_regions\", topRegions).\n\tColumnExpr(\"region\").\n\tColumnExpr(\"product\").\n\tColumnExpr(\"SUM(quantity) AS product_units\").\n\tColumnExpr(\"SUM(amount) AS product_sales\").\n\tTableExpr(\"orders\").\n\tWhere(\"region IN (SELECT region FROM top_regions)\").\n\tGroupExpr(\"region\").\n\tGroupExpr(\"product\").\n\tScan(ctx, \u0026items)\n```\n\n```sql\nWITH regional_sales AS (\n    SELECT region, SUM(amount) AS total_sales\n    FROM orders\n    GROUP BY region\n), top_regions AS (\n    SELECT region\n    FROM regional_sales\n    WHERE total_sales \u003e (SELECT SUM(total_sales)/10 FROM regional_sales)\n)\nSELECT region,\n       product,\n       SUM(quantity) AS product_units,\n       SUM(amount) AS product_sales\nFROM orders\nWHERE region IN (SELECT region FROM top_regions)\nGROUP BY region, product\n```\n\nAnd scan results into scalars, structs, maps, slices of structs/maps/scalars:\n\n```go\nusers := make([]User, 0)\nif err := db.NewSelect().Model(\u0026users).OrderExpr(\"id ASC\").Scan(ctx); err != nil {\n\tpanic(err)\n}\n\nuser1 := new(User)\nif err := db.NewSelect().Model(user1).Where(\"id = ?\", 1).Scan(ctx); err != nil {\n\tpanic(err)\n}\n```\n\nSee [**Getting started**](https://bun.uptrace.dev/guide/golang-orm.html) guide and check\n[examples](example).\n\n## See also\n\n- [Golang HTTP router](https://github.com/uptrace/bunrouter)\n- [Golang ClickHouse ORM](https://github.com/uptrace/go-clickhouse)\n- [Golang msgpack](https://github.com/vmihailenco/msgpack)\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for some hints.\n\nAnd thanks to all the people who already contributed!\n\n\u003ca href=\"https://github.com/uptrace/bun/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contributors-img.web.app/image?repo=uptrace/bun\" /\u003e\n\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuptrace%2Fbun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuptrace%2Fbun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuptrace%2Fbun/lists"}