dbo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2025 License: MIT Imports: 17 Imported by: 0

README

dbo

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Connection xConnector

Functions

func NewSession

func NewSession(db *gorm.DB) *gorm.DB

Types

type ConnectionCallback

type ConnectionCallback func(db *gorm.DB) *gorm.DB

type Connector

type Connector interface {
	Connect(callback ...ConnectionCallback) (inst Instance, err error)
}

func NewConnector

func NewConnector(opts Options) Connector

type DB

type DB struct {
	DB      *gorm.DB
	Scopes  []scopes.Scope
	Clauses []clause.Expression
	Timeout time.Duration
}

type DRIVER

type DRIVER string
const (
	DRIVER_MYSQL  DRIVER = "mysql"
	DRIVER_PGSQL  DRIVER = "pgsql"
	DRIVER_SQLITE DRIVER = "sqlite"
)

type ENGINE

type ENGINE string
const (
	ENGINE_INNODB ENGINE = "InnoDB"
)

type Instance

type Instance interface {
	Get(options ...DB) (db *gorm.DB, err error)
	WithCancel(options ...DB) (db *gorm.DB, cancel context.CancelFunc, err error)

	Migrate(models ...any) (err error)
	Seed(entries ...SeederEntry) (err error)
}

type Null

type Null[T comparable] struct {
	Data  T
	Valid bool
}

func (Null[T]) MarshalJSON

func (n Null[T]) MarshalJSON() ([]byte, error)

func (*Null[T]) Scan

func (n *Null[T]) Scan(value any) (err error)

func (*Null[T]) UnmarshalJSON

func (n *Null[T]) UnmarshalJSON(b []byte) error

func (Null[T]) Value

func (n Null[T]) Value() (driver.Value, error)

type Options

type Options struct {
	Driver          DRIVER
	Host            string
	Port            string
	Username        string
	Password        string
	DBName          string
	Charset         string
	Collation       string
	DSN             string
	Engine          ENGINE
	Config          *gorm.Config
	MaxOpenConns    int
	MaxIdleConns    int
	ConnMaxLifetime int // Maximum lifetime for a connection (in milliseconds)
	ConnMaxIdleTime int // Maximum idle time for a connection (in milliseconds)
}

type SeederEntry

type SeederEntry interface {
	Name() string
	Handler(db *gorm.DB) (err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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