dbo

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Migration dbMigration
View Source
var Seeder dbSeeder

Functions

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 Instance added in v2.1.0

type Instance interface {
	New() *gorm.DB
	DB(db ...*gorm.DB) (value *gorm.DB, err error)
	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) Instance

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
	DSN      string
}

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)

Jump to

Keyboard shortcuts

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