dbo

package module
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 21 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) (tx *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 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 struct {
	// contains filtered or unexported fields
}

func (*Instance) Get

func (x *Instance) Get(options ...O) (db *gorm.DB, err error)

func (*Instance) Migrate

func (x *Instance) Migrate(models ...any) (err error)

func (*Instance) Run added in v1.0.6

func (x *Instance) Run(db *gorm.DB, runners []Runner) (err error)

func (*Instance) RunMigration added in v1.0.6

func (x *Instance) RunMigration(models ...any) gokit.Runner

func (*Instance) RunSeeders added in v1.0.6

func (x *Instance) RunSeeders(seeders ...SeederEntry) gokit.Runner

func (*Instance) Seed

func (x *Instance) Seed(entries ...SeederEntry) (err error)

func (*Instance) WithCancel

func (x *Instance) WithCancel(options ...O) (db *gorm.DB, cancel context.CancelFunc, 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 O added in v1.0.1

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

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 Range added in v1.0.7

type Range struct {
	Offset, Limit int
}

type Runner added in v1.0.6

type Runner func(db *gorm.DB) (err error)
type Search struct {
	Text  string `query:"text"`
	Page  uint   `query:"page"`
	Limit uint   `query:"limit"`
}

func (*Search) Sanitize added in v1.0.7

func (x *Search) Sanitize() (err error)

type SeederEntry

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

type Service added in v1.0.7

type Service[T any] struct{}

func (*Service[T]) All added in v1.0.7

func (x *Service[T]) All(db *gorm.DB, extra ...Range) (value []T, err error)

func (*Service[T]) AllWithScope added in v1.0.7

func (x *Service[T]) AllWithScope(db *gorm.DB, scopeList []scopes.Scope) (value []T, err error)

func (*Service[T]) Count added in v1.0.7

func (x *Service[T]) Count(db *gorm.DB) (count int64, err error)

func (*Service[T]) CountWithScopes added in v1.0.7

func (x *Service[T]) CountWithScopes(db *gorm.DB, scopeList []scopes.Scope) (count int64, err error)

func (*Service[T]) Create added in v1.0.7

func (x *Service[T]) Create(db *gorm.DB, data T, conflict ...clause.OnConflict) (err error)

func (*Service[T]) DB added in v1.0.7

func (x *Service[T]) DB() *Instance

func (*Service[T]) Delete added in v1.0.7

func (x *Service[T]) Delete(db *gorm.DB, value any, conds ...any) (err error)

func (*Service[T]) DeletePermanently added in v1.0.7

func (x *Service[T]) DeletePermanently(db *gorm.DB, value any, conds ...any) (err error)

func (*Service[T]) DeletePermanentlyWithScopes added in v1.0.7

func (x *Service[T]) DeletePermanentlyWithScopes(db *gorm.DB, model T, scopeList []scopes.Scope) (err error)

func (*Service[T]) DeleteWithScopes added in v1.0.7

func (x *Service[T]) DeleteWithScopes(db *gorm.DB, model T, scopeList []scopes.Scope) (err error)

func (*Service[T]) Find added in v1.0.7

func (x *Service[T]) Find(db *gorm.DB, id any) (value T, err error)

func (*Service[T]) FindBy added in v1.0.7

func (x *Service[T]) FindBy(db *gorm.DB, field string, data any) (value T, err error)

func (*Service[T]) FindWhere added in v1.0.7

func (x *Service[T]) FindWhere(db *gorm.DB, conds ...any) (value T, err error)

func (*Service[T]) FindWhereLike added in v1.0.7

func (x *Service[T]) FindWhereLike(db *gorm.DB, field string, data any) (value T, err error)

func (*Service[T]) FindWithScopes added in v1.0.7

func (x *Service[T]) FindWithScopes(db *gorm.DB, scopeList []scopes.Scope) (value T, err error)

func (*Service[T]) Insert added in v1.0.7

func (x *Service[T]) Insert(db *gorm.DB, data []T, conflict ...clause.OnConflict) (err error)

func (*Service[T]) Paginate added in v1.0.7

func (x *Service[T]) Paginate(db *gorm.DB, page uint, limit uint) (value *pagination.Pagination[T], err error)

func (*Service[T]) PaginateWithScopes added in v1.0.7

func (x *Service[T]) PaginateWithScopes(db *gorm.DB, page uint, limit uint, scopeList []scopes.Scope) (value *pagination.Pagination[T], err error)

func (*Service[T]) Refresh added in v1.0.7

func (x *Service[T]) Refresh(db *gorm.DB, data T) (err error)

func (*Service[T]) Search added in v1.0.7

func (x *Service[T]) Search(db *gorm.DB, query *Search) (value *pagination.Pagination[T], err error)

func (*Service[T]) SearchWithScopes added in v1.0.7

func (x *Service[T]) SearchWithScopes(db *gorm.DB, query *Search, scopeList []scopes.Scope) (value *pagination.Pagination[T], err error)

func (*Service[T]) Some added in v1.0.7

func (x *Service[T]) Some(db *gorm.DB, offset, limit int) (value []T, err error)

func (*Service[T]) Sum added in v1.0.7

func (x *Service[T]) Sum(db *gorm.DB, column string) (value float64, err error)

func (*Service[T]) SumWithScopes added in v1.0.7

func (x *Service[T]) SumWithScopes(db *gorm.DB, column string, scopeList []scopes.Scope) (value float64, err error)

func (*Service[T]) Update added in v1.0.7

func (x *Service[T]) Update(db *gorm.DB, model T, columns []string, data any) (err error)

type Set added in v1.0.2

type Set[T xSetConstraint] struct {
	Data gokit.Array[T]
}

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

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

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

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

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

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

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

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

Directories

Path Synopsis
tests

Jump to

Keyboard shortcuts

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