emgorm

package module
v0.0.0-...-d3d9097 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

emix-gorm

database tool library

go get github.com/go-emix/emix-gorm

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectBeEmptyErr = errors.New("connect be empty")
View Source
var DefaultPageCount int64 = 10

Functions

func GetDb

func GetDb(name string) *gorm.DB

func IsEmpty

func IsEmpty(set ...DbSet) bool

func OpenConnect

func OpenConnect(op Option) (db *gorm.DB, err error)

func RFC3339

func RFC3339() string

func SetDb

func SetDb(name string, db *gorm.DB)

func SetDbFromOption

func SetDbFromOption(name string, op Option) error

func Uint8ToTime

func Uint8ToTime(ua []uint8) (time.Time, error)

Types

type DbConfig

type DbConfig struct {
	Name            string `yaml:"name"`
	Dialect         string `yaml:"dialect"`
	Connect         string `yaml:"connect"`
	MaxIdleConns    int    `yaml:"maxIdleConns"`
	MaxOpenConns    int    `yaml:"maxOpenConns"`
	ConnMaxLifetime int64  `yaml:"connMaxLifetime"`
}

func (DbConfig) Option

func (r DbConfig) Option() Option

type DbSet

type DbSet map[string]*gorm.DB

type EmixConfig

type EmixConfig struct {
	Db []DbConfig `yaml:"db,flow"`
}

type MsqlPager

type MsqlPager struct {
	PageNum   int64
	PageCount int64
	Pages     int64
	Counts    int64
	// contains filtered or unexported fields
}

func NewMsqlPager

func NewMsqlPager(db *gorm.DB, pageNum int64, pageCount int64) *MsqlPager

func (*MsqlPager) Raw

func (r *MsqlPager) Raw(sql string, values ...interface{}) *MsqlPager

func (*MsqlPager) Scan

func (r *MsqlPager) Scan(slice interface{}) error

type Operation

type Operation struct {
	// contains filtered or unexported fields
}

func AfterInit

func AfterInit(yamlFile string, cs ...DbConfig) (oper Operation)

func (Operation) Setup

func (r Operation) Setup()

type Option

type Option struct {
	Dialect         string
	Connect         string
	MaxIdleConns    int
	MaxOpenConns    int
	ConnMaxLifetime time.Duration
}

type RootConfig

type RootConfig struct {
	Emix EmixConfig `yaml:"emix"`
}

Jump to

Keyboard shortcuts

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