db

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MysqlExec

func MysqlExec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

func MysqlInit

func MysqlInit(cfg *MysqlConfig)

func MysqlInitByField

func MysqlInitByField(cfg *MysqlFieldConfig)

func MysqlQuery

func MysqlQuery(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

func Setup

func Setup(c *MongoConfig)

func SetupRawDB

func SetupRawDB(db *sql.DB)

func TimeFormat

func TimeFormat(t time.Time) string

func TimeParse

func TimeParse(s string) time.Time

func TimeParseLocalTime

func TimeParseLocalTime(s string) time.Time

func TimeToLocalTime

func TimeToLocalTime(c time.Time) string

Types

type GetMySQLOption

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

type GetMySQLOptionFunc

type GetMySQLOptionFunc func(*GetMySQLOption)

func WithDB

func WithDB(db *sql.DB) GetMySQLOptionFunc

type MongoConfig

type MongoConfig struct {
	MongoDB    string
	DBName     string
	PoolLimit  int
	MaxSession int
}

type MongoDriver

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

func NewMongoDriver

func NewMongoDriver(ctx context.Context, opts ...MongoDriverOption) (*MongoDriver, error)

func (*MongoDriver) Close

func (md *MongoDriver) Close() error

func (*MongoDriver) GetCol

func (md *MongoDriver) GetCol(cname string) *mongo.Collection

type MongoDriverOption

type MongoDriverOption func(*options.ClientOptions)

func WithPoolMonitor

func WithPoolMonitor(m *event.PoolMonitor) MongoDriverOption

type Mysql

type Mysql struct {
	*sql.DB
	// contains filtered or unexported fields
}

func GetMysql

func GetMysql(opts ...GetMySQLOptionFunc) *Mysql

func NewMysql

func NewMysql(cfg *MysqlConfig, opts ...NewMySQLOptionFunc) (*Mysql, error)

type MysqlConfig

type MysqlConfig struct {
	DataSource      string
	PoolSize        int
	ConnMaxLifeTime time.Duration
}

type MysqlFieldConfig

type MysqlFieldConfig struct {
	Addr     string
	UserName string
	Password string
	Database string

	PoolSize        int
	ConnMaxLifeTime time.Duration

	Options map[string]string
}

MysqlFieldConfig uses fields to config mysql, it can be converted to DSN style.

func (*MysqlFieldConfig) Convert

func (cfg *MysqlFieldConfig) Convert() *MysqlConfig

type NewMySQLOption

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

type NewMySQLOptionFunc

type NewMySQLOptionFunc func(*NewMySQLOption)

func WithRawDB

func WithRawDB(db *sql.DB) NewMySQLOptionFunc

Jump to

Keyboard shortcuts

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