$ account uptrace
Bun is a SQL-first Go ORM library that provides a fluent query builder, schema migration, and support for multiple database backends including PostgreSQL, MySQL, SQLite, MSSQL, and Oracle. The architecture is modular: a core package defines query types (SelectQuery, InsertQuery, etc.) and model hooks, while separate dialect packages handle SQL syntax differences and feature flags. A custom PostgreSQL driver (pgdriver) implements the wire protocol directly, and a migration system supports both versioned and auto-generated migrations via schema diffing. The library also includes extras for OpenTelemetry tracing, structured logging (slog, zerolog), New Relic integration, and a fixture loader for test data. Bun is designed for production use with connection pooling, soft deletes, CTEs, and relation handling (belongs-to, has-many, many-to-many). The codebase is well-structured with extensive test coverage, including snapshot tests for SQL generation across all supported dialects.