orm

package
v1.0.20 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRow                = sql.ErrNoRows
	ErrRecordNotFound       = gorm.ErrRecordNotFound
	ErrCantStartTransaction = gorm.ErrCantStartTransaction
	ErrInvalidSQL           = gorm.ErrInvalidSQL
	ErrInvalidTransaction   = gorm.ErrInvalidTransaction
	ErrUnaddressable        = gorm.ErrUnaddressable
)

Functions

func InitGorm

func InitGorm(c *MySQLConfig) (db *gorm.DB)

func InitXorm

func InitXorm(c *MySQLConfig) (db *xorm.Engine)

Types

type MySQLConfig

type MySQLConfig struct {
	DSN            string         // data source name.
	MaxOpenConn    int            // pool, e.g:10
	MaxIdleConn    int            // pool, e.g:100
	MaxConnTimeout xtime.Duration // connect max life time. e.g:10s、2m、1m10s
	ShowSQL        bool
}

MySQLConfig mysql config.

type Page

type Page struct {
	PageNo   int `json:"page_no"`
	PageSize int `json:"page_size"`
}

func (*Page) ApplyGorm

func (p *Page) ApplyGorm(db *gorm.DB)

func (*Page) ApplyXorm

func (p *Page) ApplyXorm(db *xorm.Session)

type Redis

type Redis struct {
	Redis *redis.Client
}

func InitRedis

func InitRedis(c *RedisConfig) (r *Redis)

func (*Redis) Transaction

func (r *Redis) Transaction(ctx context.Context, fc func(tx redis.Pipeliner) error) error

type RedisCluster

type RedisCluster struct {
	Redis *redis.ClusterClient
}

func InitRedisCluster

func InitRedisCluster(c *RedisConfig) (rc *RedisCluster)

func (*RedisCluster) Transaction

func (r *RedisCluster) Transaction(ctx context.Context, fc func(tx redis.Pipeliner) error) error

type RedisConfig

type RedisConfig struct {
	Addrs        []string
	Password     string
	DB           int
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

RedisConfig redis config.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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