dbo

package
v1.9.14 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Migration dbMigration
View Source
var Seeder dbSeeder

Functions

func DB

func DB(i Instance, db ...*gorm.DB) (value *gorm.DB, err error)

func NewPlugin added in v1.8.2

func NewPlugin() (v *xPlugin)

func NewSession

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

Types

type ConnectCallback added in v1.9.9

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

type DBSeeder added in v1.9.12

type DBSeeder interface {
	Seed(db *gorm.DB, entries []SeederEntry) (err error)
}

func NewSeeder added in v1.9.12

func NewSeeder() DBSeeder

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 {
	New() *gorm.DB
	DB(db ...*gorm.DB) (value *gorm.DB, err error)
	AddMigrations(models ...any)
	AddSeeders(handlers ...SeederHandler)
	Migrate(seed ...bool) (err error)
	Seed(entries ...SeederEntry) (err error)
}

func Connect

func Connect(opts *Options) (i Instance, err error)

func ConnectWithCallback added in v1.9.9

func ConnectWithCallback(opts *Options, callback ConnectCallback) (i Instance, err error)

func NewInstance

func NewInstance(db *gorm.DB, opts *Options) Instance

type Json

type Json[T any] struct {
	Data T
}

func (Json[T]) MarshalJSON

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

func (*Json[T]) Scan

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

func (*Json[T]) UnmarshalJSON

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

func (Json[T]) Value

func (n Json[T]) Value() (value driver.Value, 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 Pagination

type Pagination[T any] struct {
	CurrentPage uint `json:"current_page"`
	From        uint `json:"from"`
	LastPage    uint `json:"last_page"`
	PerPage     int  `json:"per_page"`
	To          uint `json:"to"`
	Total       uint `json:"total"`
	Data        []T  `json:"data"`
}

func Paginate

func Paginate[T any](tx *gorm.DB, page uint, limit ...uint) (value *Pagination[T], err error)

type SeederEntry added in v1.9.10

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

type SeederHandler

type SeederHandler func(db *gorm.DB) (err error)

type Set added in v1.8.1

type Set[T gokit.SetConstraint] struct {
	Data []T
}

func (Set[T]) MarshalJSON added in v1.8.1

func (x Set[T]) MarshalJSON() ([]byte, error)

func (*Set[T]) Scan added in v1.8.1

func (x *Set[T]) Scan(value any) (err error)

func (*Set[T]) UnmarshalJSON added in v1.8.1

func (x *Set[T]) UnmarshalJSON(b []byte) error

func (Set[T]) Value added in v1.8.1

func (x Set[T]) Value() (value driver.Value, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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