dbo

package module
v1.0.1 Latest Latest
Warning

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

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

README

DBO

The awesome DBO library for Golang, aims to bring developer friendliness to just about every project using the GORM package.

Go Report Card Test Status MIT license Go.Dev reference

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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
tests

Jump to

Keyboard shortcuts

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