xdb

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmptyVal    = ""
	PartOnlyOne = 1
)
View Source
const (
	// MYSQL dbType
	MYSQL = "mysql"
	// PG dbType
	PG = "postgres"
)

Variables

This section is empty.

Functions

func DB

func DB() *gorm.DB

DB 获取数据库链接

func GetAutoSliceDB added in v1.2.6

func GetAutoSliceDB(db *gorm.DB, userId int64, sf SP) *gorm.DB

GetAutoSliceDB 获取自动分表

func InitQpsDB added in v1.2.6

func InitQpsDB(limit int, interval time.Duration)

InitQpsDB 初始化同步等待QPS DB

func OpenMysqlDB

func OpenMysqlDB(dbType string, dbUrl string, config *gorm.Config, maxIdleConns, maxOpenConns int, models ...interface{}) (instance *gorm.DB, err error)

OpenMysqlDB gorm v2 dbUrl = username:password@tcp(localhost:3306)/db_name?charset=utf8mb4&parseTime=True&loc=Local

func QpsDB added in v1.3.3

func QpsDB() *gorm.DB

QpsDB 获取DB对象,若超时则返回nil

func SetMainDB added in v1.4.4

func SetMainDB(main *gorm.DB, DSN string)

SetMainDB 设置主DB

Types

type SP added in v1.2.6

type SP struct {
	Value  interface{}
	Part   int64  // 用户ID取余分表
	ByDate string // 通过日期2022-01-01分表,按月,按日
}

Jump to

Keyboard shortcuts

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