mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-11-25 01:41:00 +00:00
a156188b3e
* update dependencies, bump Go version to 1.19 * bump test image Go version * update golangci-lint * update gotosocial-drone-build * sign * linting, go fmt * update swagger docs * update swagger docs * whitespace * update contributing.md * fuckin whoopsie doopsie * linterino, linteroni * fix followrequest test not starting processor * fix other api/client tests not starting processor * fix remaining tests where processor not started * bump go-runners version * don't check last-webfingered-at, processor may have updated this * update swagger command * update bun to latest version * fix embed to work the same as before with new bun Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com> |
||
---|---|---|
.. | ||
dialect | ||
extra/bunjson | ||
internal | ||
migrate | ||
schema | ||
.gitignore | ||
.prettierrc.yml | ||
bun.go | ||
CHANGELOG.md | ||
commitlint.config.js | ||
CONTRIBUTING.md | ||
db.go | ||
hook.go | ||
LICENSE | ||
Makefile | ||
model.go | ||
model_map.go | ||
model_map_slice.go | ||
model_scan.go | ||
model_slice.go | ||
model_table_has_many.go | ||
model_table_m2m.go | ||
model_table_slice.go | ||
model_table_struct.go | ||
package.json | ||
query_base.go | ||
query_column_add.go | ||
query_column_drop.go | ||
query_delete.go | ||
query_index_create.go | ||
query_index_drop.go | ||
query_insert.go | ||
query_raw.go | ||
query_select.go | ||
query_table_create.go | ||
query_table_drop.go | ||
query_table_truncate.go | ||
query_update.go | ||
query_values.go | ||
README.md | ||
relation_join.go | ||
util.go | ||
version.go |
SQL-first Golang ORM for PostgreSQL, MySQL, MSSQL, and SQLite
Bun is brought to you by ⭐ uptrace/uptrace. Uptrace is an open source and blazingly fast distributed tracing tool powered by OpenTelemetry and ClickHouse. Give it a star as well!
Features
- Works with PostgreSQL, MySQL (including MariaDB), MSSQL, SQLite.
- ORM-like experience using good old SQL. Bun supports structs, map, scalars, and slices of map/structs/scalars.
- Bulk inserts.
- Bulk updates using common table expressions.
- Bulk deletes.
- Fixtures.
- Migrations.
- Soft deletes.
Resources:
Featured projects using Bun:
- uptrace - Distributed tracing and metrics.
- paralus - All-in-one Kubernetes access manager.
- inovex/scrumlr.io - Webapp for collaborative online retrospectives.
- gotosocial - Golang fediverse server.
- lorawan-stack - The Things Stack, an Open Source LoRaWAN Network Server.
- anti-phishing-bot - Discord bot for deleting Steam/Discord phishing links.
- emerald-web3-gateway - Web3 Gateway for the Oasis Emerald paratime.
- lndhub.go - accounting wrapper for the Lightning Network.
- penguin-statistics - Penguin Statistics v3 Backend.
- And hundreds more.
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
Contributors
Thanks to all the people who already contributed!