Skip to content

uptrace/bun

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

b9e6480 · Jan 8, 2024
Sep 27, 2023
Sep 18, 2023
Sep 16, 2023
Sep 16, 2023
Jan 6, 2024
Oct 1, 2023
Jan 8, 2024
May 24, 2023
Sep 16, 2023
May 6, 2023
Oct 1, 2023
Oct 19, 2021
Sep 16, 2023
Mar 26, 2022
May 6, 2021
May 24, 2023
Dec 12, 2022
Jul 1, 2023
Sep 11, 2021
Dec 6, 2022
Sep 10, 2023
Sep 10, 2023
Nov 24, 2022
Mar 5, 2023
Oct 22, 2021
Oct 22, 2021
Oct 22, 2021
Sep 25, 2021
Sep 25, 2021
Sep 25, 2021
Feb 20, 2023
Sep 10, 2023
Sep 16, 2023
Sep 10, 2023
Jan 8, 2023
Jan 8, 2023
Jan 8, 2023
Jan 8, 2023
Jan 8, 2023
Jan 8, 2023
Jan 6, 2024
Feb 28, 2023
Dec 11, 2023
Jan 8, 2023
Jan 8, 2023
Jan 8, 2023
Jan 6, 2024
Jan 8, 2023
Sep 10, 2023
Dec 6, 2022
Sep 16, 2023

Repository files navigation

SQL-first Golang ORM for PostgreSQL, MySQL, MSSQL, and SQLite

build workflow PkgGoDev Documentation Chat

Bun is brought to you by ⭐ uptrace/uptrace. Uptrace is an open-source APM tool that supports distributed tracing, metrics, and logs. You can use it to monitor applications and set up automatic alerts to receive notifications via email, Slack, Telegram, and others.

See OpenTelemetry example which demonstrates how you can use Uptrace to monitor Bun.

Features

Resources

Tutorials

Wrote a tutorial for Bun? Create a PR to add here and on Bun site.

Featured projects using Bun

Why another database client?

So you can elegantly write complex queries:

regionalSales := db.NewSelect().
	ColumnExpr("region").
	ColumnExpr("SUM(amount) AS total_sales").
	TableExpr("orders").
	GroupExpr("region")

topRegions := db.NewSelect().
	ColumnExpr("region").
	TableExpr("regional_sales").
	Where("total_sales > (SELECT SUM(total_sales) / 10 FROM regional_sales)")

var items []map[string]interface{}
err := db.NewSelect().
	With("regional_sales", regionalSales).
	With("top_regions", topRegions).
	ColumnExpr("region").
	ColumnExpr("product").
	ColumnExpr("SUM(quantity) AS product_units").
	ColumnExpr("SUM(amount) AS product_sales").
	TableExpr("orders").
	Where("region IN (SELECT region FROM top_regions)").
	GroupExpr("region").
	GroupExpr("product").
	Scan(ctx, &items)
WITH regional_sales AS (
    SELECT region, SUM(amount) AS total_sales
    FROM orders
    GROUP BY region
), top_regions AS (
    SELECT region
    FROM regional_sales
    WHERE total_sales > (SELECT SUM(total_sales)/10 FROM regional_sales)
)
SELECT region,
       product,
       SUM(quantity) AS product_units,
       SUM(amount) AS product_sales
FROM orders
WHERE region IN (SELECT region FROM top_regions)
GROUP BY region, product

And scan results into scalars, structs, maps, slices of structs/maps/scalars:

users := make([]User, 0)
if err := db.NewSelect().Model(&users).OrderExpr("id ASC").Scan(ctx); err != nil {
	panic(err)
}

user1 := new(User)
if err := db.NewSelect().Model(user1).Where("id = ?", 1).Scan(ctx); err != nil {
	panic(err)
}

See Getting started guide and check examples.

See also

Contributing

See CONTRIBUTING.md for some hints.

And thanks to all the people who already contributed!