xxdb

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2025 License: MulanPSL-2.0 Imports: 14 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

设置缺省分页

View Source
var RedisDao = new(redisDao)

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 NewRedisDao added in v0.1.5

func NewRedisDao(redis *redis.Client) *redisDao

func Paginate added in v0.1.5

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

分页封装

func PaginatePage added in v0.1.5

func PaginatePage(p *Pages) func(db *gorm.DB) *gorm.DB

参考 https://www.cnblogs.com/leijiangsheng/p/16533014.html

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
	Logger logger.Interface
}

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 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
JackTT - Gopher 🇻🇳