bunconnector

package module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 21 Imported by: 0

README

Lemmego Bun Connector

The bunconnector plugin for the Lemmego framework. Provides database connectivity using uptrace/bun with optional GPA integration.

Usage

// With GPA
&bunconnector.Provider{UseGPA: true}

// Without GPA (raw *bun.DB)
&bunconnector.Provider{UseGPA: false}

CLI Commands

  • bun:model — Generate a Bun model with bun: struct tags
  • bun:repo — Generate a repository with GPA integration

Supported Drivers

  • PostgreSQL (postgres, postgresql)
  • MySQL (mysql)
  • SQLite (sqlite, sqlite3)

Documentation

Index

Constants

View Source
const (
	RelationOneToOne   = "one_to_one"
	RelationOneToMany  = "one_to_many"
	RelationManyToOne  = "many_to_one"
	RelationManyToMany = "many_to_many"
)

Variables

View Source
var CommonModelFields = []*ModelField{
	{
		Name:     "id",
		Type:     "uint64",
		Required: true,
		Primary:  true,
	},
	{
		Name:     "created_at",
		Type:     "time.Time",
		Required: true,
	},
	{
		Name:     "updated_at",
		Type:     "time.Time",
		Required: true,
	},
	{
		Name: "deleted_at",
		Type: "time.Time",
	},
}

Functions

func Get

func Get(a app.App) *gpabun.Provider

func NewBunConnection

func NewBunConnection(config gpa.Config) (*bun.DB, error)

func SupportedDrivers

func SupportedDrivers() []string

Types

type ModelConfig

type ModelConfig struct {
	Name   string
	Fields []*ModelField
}

type ModelField

type ModelField struct {
	Name               string
	Type               string
	Required           bool
	Unique             bool
	Primary            bool
	ForeignConstrained bool
	Relation           string
}

type ModelGenerator

type ModelGenerator struct {
	// contains filtered or unexported fields
}

func NewModelGenerator

func NewModelGenerator(mc *ModelConfig) *ModelGenerator

func (*ModelGenerator) Generate

func (mg *ModelGenerator) Generate(appendable ...[]byte) error

func (*ModelGenerator) GetPackagePath

func (mg *ModelGenerator) GetPackagePath() string

func (*ModelGenerator) GetStub

func (mg *ModelGenerator) GetStub() string

type Provider

type Provider struct {
	UseGPA bool
	// contains filtered or unexported fields
}

func (*Provider) AddCommands

func (b *Provider) AddCommands() []app.Command

func (*Provider) Dialect added in v0.1.4

func (b *Provider) Dialect() db.Dialect

Dialect reports the SQL flavour of the open connection.

func (*Provider) Name added in v0.1.4

func (b *Provider) Name() string

Name reports which sql.connections key this connection was built from.

func (*Provider) Provide

func (b *Provider) Provide(a app.App) error

func (*Provider) SQLDB added in v0.1.4

func (b *Provider) SQLDB() *sql.DB

SQLDB returns the underlying connection. It is half of db.Connection, and is spelled the same way in every connector so the seam has one name.

func (*Provider) Shutdown

func (b *Provider) Shutdown(ctx context.Context) error

func (*Provider) WithGPAConfig

func (b *Provider) WithGPAConfig(config gpa.Config) *Provider

type RepoConfig

type RepoConfig struct {
	Name string
}

type RepoGenerator

type RepoGenerator struct {
	// contains filtered or unexported fields
}

func NewRepoGenerator

func NewRepoGenerator(rc *RepoConfig) *RepoGenerator

func (*RepoGenerator) Generate

func (rg *RepoGenerator) Generate(appendable ...[]byte) error

func (*RepoGenerator) GetPackagePath

func (rg *RepoGenerator) GetPackagePath() string

func (*RepoGenerator) GetStub

func (rg *RepoGenerator) GetStub() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址