Help us shape the future of Go! Take the 2026 Go Developer Survey

bunconnector

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 20 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) GetSQLDb

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

func (*Provider) Provide

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

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