dbx

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGroupName = "default"
)

Variables

This section is empty.

Functions

func AddConfigNode

func AddConfigNode(group string, node ConfigNode)

func AddDefaultConfigNode

func AddDefaultConfigNode(node ConfigNode)

func AddDefaultConfigNodeGroup

func AddDefaultConfigNodeGroup(nodes ConfigGroup)

func GetDefaultGroup

func GetDefaultGroup() string

func SetConfig

func SetConfig(config Config)

func SetConfigGroup

func SetConfigGroup(group string, nodes ConfigGroup)

func SetDefaultGroup

func SetDefaultGroup(name string)

Types

type Config

type Config map[string]ConfigGroup

type ConfigGroup

type ConfigGroup []ConfigNode

func GetConfig

func GetConfig(group string) ConfigGroup

type ConfigNode

type ConfigNode struct {
	Host                 string        `json:"host"`                 // Host of server, ip or domain like: 127.0.0.1, localhost
	Port                 string        `json:"port"`                 // Port, it's commonly 3306.
	User                 string        `json:"user"`                 // Authentication username.
	Pass                 string        `json:"pass"`                 // Authentication password.
	Name                 string        `json:"name"`                 // Default used database name.
	Type                 string        `json:"type"`                 // Database type: mysql, sqlite, mssql, pgsql, oracle.
	Link                 string        `json:"link"`                 // (Optional) Custom link information for all configuration in one single string.
	Extra                string        `json:"extra"`                // (Optional) Extra configuration according the registered third-party database driver.
	Role                 string        `json:"role"`                 // (Optional, "master" in default) Node role, used for master-slave mode: master, slave.
	Debug                bool          `json:"debug"`                // (Optional) Debug mode enables debug information logging and output.
	Prefix               string        `json:"prefix"`               // (Optional) Table prefix.
	DryRun               bool          `json:"dryRun"`               // (Optional) Dry run, which does SELECT but no INSERT/UPDATE/DELETE statements.
	Weight               int           `json:"weight"`               // (Optional) Weight for load balance calculating, it's useless if there's just one node.
	Charset              string        `json:"charset"`              // (Optional, "utf8mb4" in default) Custom charset when operating on database.
	Protocol             string        `json:"protocol"`             // (Optional, "tcp" in default) See net.Dial for more information which networks are available.
	Timezone             string        `json:"timezone"`             // (Optional) Sets the time zone for displaying and interpreting time stamps.
	MaxIdleConnCount     int           `json:"maxIdle"`              // (Optional) Max idle connection configuration for underlying connection pool.
	MaxOpenConnCount     int           `json:"maxOpen"`              // (Optional) Max open connection configuration for underlying connection pool.
	MaxConnLifeTime      time.Duration `json:"maxLifeTime"`          // (Optional) Max amount of time a connection may be idle before being closed.
	QueryTimeout         time.Duration `json:"queryTimeout"`         // (Optional) Max query time for per dql.
	ExecTimeout          time.Duration `json:"execTimeout"`          // (Optional) Max exec time for dml.
	TranTimeout          time.Duration `json:"tranTimeout"`          // (Optional) Max exec time time for a transaction.
	PrepareTimeout       time.Duration `json:"prepareTimeout"`       // (Optional) Max exec time time for prepare operation.
	CreatedAt            string        `json:"createdAt"`            // (Optional) The filed name of table for automatic-filled created datetime.
	UpdatedAt            string        `json:"updatedAt"`            // (Optional) The filed name of table for automatic-filled updated datetime.
	DeletedAt            string        `json:"deletedAt"`            // (Optional) The filed name of table for automatic-filled updated datetime.
	TimeMaintainDisabled bool          `json:"timeMaintainDisabled"` // (Optional) Disable the automatic time maintaining feature.

}

type OrderDirection

type OrderDirection int
const (
	OrderByASC OrderDirection = iota + 1
	OrderByDESC
)

type OrderField

type OrderField struct {
	Key       string
	Direction OrderDirection
}

func NewOrderField

func NewOrderField(key string, d OrderDirection) *OrderField

func NewOrderFieldWithKeys

func NewOrderFieldWithKeys(keys []string, directions ...map[int]OrderDirection) []*OrderField

Create order fields key and define key index direction

func NewOrderFields

func NewOrderFields(orderFields ...*OrderField) []*OrderField

type PaginationParam

type PaginationParam struct {
	Pagination bool `form:"-"`
	OnlyCount  bool `form:"-"`
	Offset     int  `form:"Offset,default=1"`
	Limit      int  `form:"limit,default=20" binding:"max=100"`
}

func (PaginationParam) GetCurrent

func (a PaginationParam) GetCurrent() int

func (PaginationParam) GetPageSize

func (a PaginationParam) GetPageSize() int

type PaginationResult

type PaginationResult struct {

	// 页码
	Offset int `json:"offset"`
	// 每页的条数
	Limit int `json:"limit"`
	//总行数
	TotalCount int `json:"total_count"`
}

func (*PaginationResult) GetOffset

func (p *PaginationResult) GetOffset() int

func (*PaginationResult) TotalPage

func (p *PaginationResult) TotalPage() int

Jump to

Keyboard shortcuts

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