A lightweight, SQL-first Golang ORM supporting PostgreSQL, MySQL, MSSQL, SQLite, and Oracle with type safety and flexible scanning.
Bun is a SQL-first Object-Relational Mapper (ORM) for the Go programming language. It allows developers to write complex SQL queries in a type-safe, Go-native way while supporting multiple databases like PostgreSQL, MySQL, and SQLite. It solves the problem of balancing SQL flexibility with Go's performance and safety, avoiding the overhead and opacity of traditional ORMs.
Go developers building data-intensive applications who need fine-grained control over SQL queries without sacrificing type safety or performance. It's particularly suited for teams working across multiple database backends.
Developers choose Bun for its SQL-first philosophy that doesn't hide SQL behind abstraction layers, its multi-database support with consistent APIs, and its production-ready features like migrations and OpenTelemetry integration. It offers a lightweight alternative to heavier ORMs while maintaining Go's idiomatic patterns.
SQL-first Golang ORM
Bun's SQL-first approach allows developers to write complex, readable queries using Go syntax, as demonstrated in the README with CTEs and subqueries that mirror raw SQL.
It supports PostgreSQL, MySQL, SQLite, MSSQL, and Oracle with consistent APIs, enabling code portability across different SQL backends without major rewrites.
Leverages Go's static typing to provide compile-time safety for database operations, reducing runtime errors and enhancing code reliability.
Includes built-in features like migrations, fixtures, soft deletes, and OpenTelemetry integration, making it suitable for deployment in scalable applications.
Since Bun doesn't abstract SQL away, developers need solid SQL knowledge to use it effectively, which can be a barrier for teams with limited database expertise.
As a newer ORM, Bun has a smaller community and fewer third-party extensions compared to established alternatives like GORM, potentially limiting out-of-the-box solutions.
While it supports migrations, Bun lacks automatic schema generation from models, requiring developers to write and maintain migration scripts manually, increasing setup complexity.
The fantastic ORM library for Golang, aims to be developer friendly
An entity framework for Go
Generate a Go ORM tailored to your database schema.
Go Relational Persistence - an ORM-ish library for Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.