mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-11-08 05:09:30 -06:00
update dependencies (#296)
This commit is contained in:
parent
2aaec82732
commit
829a934d23
124 changed files with 2453 additions and 1588 deletions
77
vendor/github.com/uptrace/bun/README.md
generated
vendored
77
vendor/github.com/uptrace/bun/README.md
generated
vendored
|
|
@ -30,8 +30,7 @@ Main features are:
|
|||
|
||||
Resources:
|
||||
|
||||
- To ask questions, join [Discord](https://discord.gg/rWtp5Aj) or use
|
||||
[Discussions](https://github.com/uptrace/bun/discussions).
|
||||
- [Discussions](https://github.com/uptrace/bun/discussions).
|
||||
- [Newsletter](https://blog.uptrace.dev/pages/newsletter.html) to get latest updates.
|
||||
- [Examples](https://github.com/uptrace/bun/tree/master/example)
|
||||
- [Documentation](https://bun.uptrace.dev/)
|
||||
|
|
@ -41,6 +40,7 @@ Resources:
|
|||
Projects using Bun:
|
||||
|
||||
- [gotosocial](https://github.com/superseriousbusiness/gotosocial) - Golang fediverse server.
|
||||
- [input-output-hk/cicero](https://github.com/input-output-hk/cicero)
|
||||
- [RealWorld app](https://github.com/go-bun/bun-realworld-app)
|
||||
|
||||
<details>
|
||||
|
|
@ -95,6 +95,55 @@ Projects using Bun:
|
|||
|
||||
</details>
|
||||
|
||||
## Why another database client?
|
||||
|
||||
So you can elegantly write complex queries:
|
||||
|
||||
```go
|
||||
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)")
|
||||
|
||||
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)
|
||||
```
|
||||
|
||||
```sql
|
||||
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
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```go
|
||||
|
|
@ -149,30 +198,6 @@ err := db.NewSelect().
|
|||
Scan(ctx)
|
||||
```
|
||||
|
||||
The code above is equivalent to:
|
||||
|
||||
```go
|
||||
query := "SELECT id, name FROM users AS user WHERE name != '' ORDER BY id ASC LIMIT 1"
|
||||
|
||||
rows, err := sqldb.QueryContext(ctx, query)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if !rows.Next() {
|
||||
panic(sql.ErrNoRows)
|
||||
}
|
||||
|
||||
user := new(User)
|
||||
if err := db.ScanRow(ctx, rows, user); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := rows.Err(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
```
|
||||
|
||||
## Basic example
|
||||
|
||||
To provide initial data for our [example](/example/basic/), we will use Bun
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue