db

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SQLite     = "sqlite"
	MySQL      = "mysql"
	Postgres   = "postgres"
	Clickhouse = "clickhouse"
)

Variables

This section is empty.

Functions

func WrapContext

func WrapContext(ctx context.Context, tx *gorm.DB) context.Context

Types

type Manager

type Manager interface {
	// business
	model.Database
	// lifecycle
	common.Initializable
	common.Debuggable
}

func New

func New(opts ...Option) Manager

type Option

type Option func(*manager)

func WithConnection

func WithConnection(maxOpen int, maxIdle int, maxLifetime time.Duration, maxIdleTime time.Duration, execTimeout time.Duration) Option

func WithDataSource

func WithDataSource(source Source) Option

func WithLogger

func WithLogger(logger log.Logger) Option

func WithMigration

func WithMigration(sqlDir string, version uint) Option

func WithName

func WithName(name string) Option

func WithType

func WithType(dbtype string) Option

type Source

type Source struct {
	Host     string
	Port     uint
	User     string
	Password string `print:"-"`
	DBName   string
	Secure   bool
	Params   map[string]string
}

func (*Source) DSN

func (s *Source) DSN(dbtype string) (string, error)

Jump to

Keyboard shortcuts

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