xxdb

package
v0.1.36 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2025 License: MulanPSL-2.0 Imports: 15 Imported by: 0

Documentation

Overview

@auther fenglei

@auther fenglei

@auther fenglei

@auther fenglei

@auther fenglei

@auther fenglei

@auther fenglei

@auther fenglei

Index

Constants

This section is empty.

Variables

View Source
var DBDefaultPageSize = 10

设置缺省分页

Functions

func CloseMongo added in v0.1.5

func CloseMongo(mongo *mongo.Client) error

func CloseMySQL

func CloseMySQL(db *gorm.DB) error

func CloseRedis added in v0.1.6

func CloseRedis(redis *redis.Client) error

func GenMySQL

func GenMySQL(dns string, tables ...string) error

func GormError

func GormError(err error) bool

func GormToMap

func GormToMap(v any) map[string]interface{}

func GormWhere

func GormWhere(wheres map[string]map[string]interface{}) func(db *gorm.DB) *gorm.DB

func MongoPage added in v0.1.5

func MongoPage(p *Pages) (findOptions options.FindOptions)

func NewMongo added in v0.1.5

func NewMongo(opts *MongoOptions) (*mongo.Client, error)

NewMySQL create a new gorm db instance with the given options.

func NewMySQL

func NewMySQL(opts *MySQLOptions) (*gorm.DB, error)

NewMySQL create a new gorm db instance with the given options.

func NewRedis added in v0.1.5

func NewRedis(opts *RedisOptions) (*redis.Client, error)

func Paginate added in v0.1.5

func Paginate(page int, pageSize int) func(db *gorm.DB) *gorm.DB

分页封装

Types

type MongoOptions added in v0.1.5

type MongoOptions struct {
	DSN         string
	MaxPoolSize int
}

type MySQLOptions

type MySQLOptions struct {
	DSN                   string
	MaxIdleConnections    int
	MaxOpenConnections    int
	MaxConnectionLifeTime time.Duration
	// +optional
	LogLevel logger.LogLevel
}

MySQLOptions defines options for mysql database.

type Pages added in v0.1.5

type Pages struct {
	Page     int `json:"page"`
	PageSize int `json:"pageSize"`
}

type RedisDao added in v0.1.5

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

func NewRedisDao added in v0.1.5

func NewRedisDao(redis *redis.Client) *RedisDao

func (*RedisDao) Del added in v0.1.30

func (e *RedisDao) Del(key string) error

func (*RedisDao) Exists added in v0.1.30

func (e *RedisDao) Exists(keys ...string) bool

func (*RedisDao) GetJson added in v0.1.30

func (e *RedisDao) GetJson(key string, val interface{}) error

func (*RedisDao) GetScan added in v0.1.30

func (e *RedisDao) GetScan(key string, val interface{}) error

func (*RedisDao) ScanKeys added in v0.1.30

func (e *RedisDao) ScanKeys(prefix string, limit int64) ([]string, error)

func (*RedisDao) Set added in v0.1.30

func (e *RedisDao) Set(key string, val interface{}, expiration time.Duration) error

func (*RedisDao) SetJson added in v0.1.30

func (e *RedisDao) SetJson(key string, val interface{}, expiration time.Duration) error

type RedisOptions added in v0.1.5

type RedisOptions struct {
	DSN string
}

Jump to

Keyboard shortcuts

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