Bun Store
SQL store using the Bun ORM.
The Bun store uses the Bun ORM for database access. It provides struct-based models and supports PostgreSQL.
Usage
import "github.com/xraph/relay/store/bunstore"
s, err := bunstore.New(bunstore.Config{
DSN: "postgres://user:pass@localhost:5432/relay?sslmode=disable",
})
if err != nil {
log.Fatal(err)
}
if err := s.Migrate(ctx); err != nil {
log.Fatal(err)
}
r, err := relay.New(relay.WithStore(s))Internals
| Aspect | Detail |
|---|---|
| ORM | Bun v1 with struct-based models |
| Migrations | Bun migrator with Go-defined migrations |
| Transactions | Database-level ACID |
| Ping | db.PingContext(ctx) |
| Close | Closes the connection pool |
When to use
- When you prefer an ORM over raw SQL.
- Teams familiar with Bun.