db

package
v1.0.14 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const BasicDateFormat = "2006-01-02"

BasicDateFormat for time format layout

View Source
const BasicDatetimeFormat = "2006-01-02 15:04:05"

BasicDatetimeFormat for time format layout

View Source
const DefaultPage = 1

DefaultPage value

View Source
const DefaultPageSize = 10

DefaultPageSize value

View Source
const MaxPage = 100

MaxPage limit

View Source
const MaxPageSize = 1000

MaxPageSize limit

View Source
const StatusActive = 1

StatusActive for data status active

View Source
const StatusDelete = 0

StatusDelete for data status delete

View Source
const StatusDisable = 4

StatusDisable for data status disabled

View Source
const StatusInitialize = 0

StatusInitialize for data status init

Variables

View Source
var ErrorConnNameExist = errors.New("given conn name exist")
View Source
var MySQL *xorm.Engine

MySQL client in global

View Source
var Redis *redis.Pool

Redis client in global

Functions

func Delete added in v1.0.5

func Delete(s string, args ...interface{}) (int64, error)

func ExecuteSQL

func ExecuteSQL(sqlOrArgs ...interface{}) (int64, error)

ExecuteSQL TL;DR return affected count

func GetMySQLClient

func GetMySQLClient(c conf.MySQLConfig) *xorm.Engine

GetMySQLClient init connection once

func GetRedisClient

func GetRedisClient(cfg conf.RedisConfig) *redis.Pool

GetRedisClient of redis pool

func GetRedisPool added in v1.0.11

func GetRedisPool(name string) *redis.Pool

func InitClient

func InitClient()

InitClient db connections call this func after conf.Config loaded after InitClient success, db.Redis / db.MySQL can use in global context

func InitRedisPool added in v1.0.11

func InitRedisPool(cfg conf.RedisConfig) *redis.Pool

func Insert added in v1.0.5

func Insert(s string, args ...interface{}) (int64, error)

func SetRedisPool added in v1.0.11

func SetRedisPool(name string, cfg conf.RedisConfig) error

SetRedisPool @Description: this is not goroutine safe, call the func in main process @param name @param cfg @return error

func Update added in v1.0.5

func Update(s string, args ...interface{}) (int64, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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