dbo

package
v2.4.4 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 13 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 NewSession

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

Types

type DRIVER

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

type ENGINE added in v2.3.4

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

type Instance added in v2.1.0

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() (err error)
}

func Connect added in v2.1.0

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

func NewInstance added in v2.1.0

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

type Json added in v2.3.0

type Json[T any] struct {
	Data T
}

func (Json[T]) MarshalJSON added in v2.3.0

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

func (*Json[T]) Scan added in v2.3.0

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

func (*Json[T]) UnmarshalJSON added in v2.3.0

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

func (Json[T]) Value added in v2.3.0

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
}

type Pagination

type Pagination[T any] struct {
	Current_page uint `json:"current_page"`
	From         uint `json:"from"`
	Last_page    uint `json:"last_page"`
	Per_page     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 SeederHandler added in v2.1.0

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

type Set added in v2.3.0

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

func (Set[T]) MarshalJSON added in v2.3.0

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

func (*Set[T]) Scan added in v2.3.0

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

func (*Set[T]) UnmarshalJSON added in v2.3.0

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

func (Set[T]) Value added in v2.3.0

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

Jump to

Keyboard shortcuts

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