Dispatch

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

AspectDetail
ORMBun v1 with struct-based models
MigrationsBun migrator with Go-defined migrations
TransactionsDatabase-level ACID
Pingdb.PingContext(ctx)
CloseCloses the connection pool

When to use

  • When you prefer an ORM over raw SQL.
  • Teams familiar with Bun.

On this page