dbs

package
v0.0.0-...-3831edb Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LoggingHook

type LoggingHook struct {
	logger.Logger
}

func NewLoggingHook

func NewLoggingHook(log *logger.Logger) *LoggingHook

func (*LoggingHook) AfterProcess

func (h *LoggingHook) AfterProcess(ctx context.Context, cmd redis.Cmder) error

func (*LoggingHook) AfterProcessPipeline

func (h *LoggingHook) AfterProcessPipeline(ctx context.Context, cmds []redis.Cmder) error

func (*LoggingHook) BeforeProcess

func (h *LoggingHook) BeforeProcess(ctx context.Context, cmd redis.Cmder) (context.Context, error)

func (*LoggingHook) BeforeProcessPipeline

func (h *LoggingHook) BeforeProcessPipeline(ctx context.Context, cmds []redis.Cmder) (context.Context, error)

type MongoConfig

type MongoConfig struct {
	Uri              string           `json:"uri"`
	Database         string           `json:"database"`
	Coll             string           `json:"coll"`
	ConnectTimeoutMS *int64           `json:"connectTimeoutMS"`
	MaxPoolSize      *uint64          `json:"maxPoolSize"`
	MinPoolSize      *uint64          `json:"minPoolSize"`
	SocketTimeoutMS  *int64           `json:"socketTimeoutMS"`
	ReadPreference   *qmgo.ReadPref   `json:"readPreference"`
	Auth             *qmgo.Credential `json:"auth"`
}

type MongoDb

type MongoDb struct {
	*MongoSession
}

func NewMongoDb

func NewMongoDb(uri string, database string) (*MongoDb, error)

type MongoSession

type MongoSession struct {
	Uri    string
	Client *qmgo.Client
	Db     *qmgo.Database
	DbName string
	// contains filtered or unexported fields
}

func NewMongoSession

func NewMongoSession(uri string, database string) (*MongoSession, error)

func (*MongoSession) Count

func (session *MongoSession) Count(tableName string, query bson.M) (int64, error)

Count 查询个数

func (*MongoSession) CreateIndexes

func (session *MongoSession) CreateIndexes(tableName string, keyNames []string) error

CreateIndexes 创建多个索引

func (*MongoSession) CreateOneIndex

func (session *MongoSession) CreateOneIndex(tableName string, keyName string) error

CreateOneIndex 创建单个索引

func (*MongoSession) DeleteById

func (session *MongoSession) DeleteById(tableName string, id string) error

DeleteById 根据Id删除

func (*MongoSession) DeleteMany

func (session *MongoSession) DeleteMany(tableName string, query interface{}) (*qmgo.DeleteResult, error)

DeleteMany 删除多个

func (*MongoSession) DeleteOne

func (session *MongoSession) DeleteOne(tableName string, query interface{}) error

DeleteOne 根据条件删除

func (*MongoSession) DoTransaction

func (session *MongoSession) DoTransaction(callback func(sessCtx context.Context) (interface{}, error)) (interface{}, error)

DoTransaction 事务

func (*MongoSession) Find

func (session *MongoSession) Find(tableName string, params bson.M, selectParams bson.M, limit int64, skip int64, sort []string, ret interface{}) error

Find 查询多个

func (*MongoSession) FindById

func (session *MongoSession) FindById(tableName string, id string, data interface{}) error

FindById 查询一个

func (*MongoSession) FindOne

func (session *MongoSession) FindOne(tableName string, params bson.M, selectParams bson.M, data interface{}) error

FindOne 查询一个

func (*MongoSession) GetCollection

func (session *MongoSession) GetCollection(tableName string) *qmgo.Collection

GetCollection 获取collection

func (*MongoSession) InsertMany

func (session *MongoSession) InsertMany(tableName string, params []interface{}) ([]string, error)

InsertMany 插入多个

func (*MongoSession) InsertOne

func (session *MongoSession) InsertOne(tableName string, updateInfo interface{}) (string, error)

InsertOne 插入一个

func (*MongoSession) SetLogger

func (session *MongoSession) SetLogger(log *logger.Logger)

func (*MongoSession) SetTimeOut

func (session *MongoSession) SetTimeOut(timeout time.Duration)

SetTimeOut 设置超时

func (*MongoSession) UpdateById

func (session *MongoSession) UpdateById(tableName string, id string, params interface{}) error

UpdateById 根据id更新

func (*MongoSession) UpdateMany

func (session *MongoSession) UpdateMany(tableName string, query interface{}, params interface{}) error

UpdateMany 更新多个文档

func (*MongoSession) UpdateOne

func (session *MongoSession) UpdateOne(tableName string, query interface{}, params interface{}) error

UpdateOne 更新单个

func (*MongoSession) Upsert

func (session *MongoSession) Upsert(tableName string, filter interface{}, params interface{}) (*qmgo.UpdateResult, error)

func (*MongoSession) UpsertById

func (session *MongoSession) UpsertById(tableName string, id string, params interface{}) (*qmgo.UpdateResult, error)

type MysqlDb

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

func NewMysqlDb

func NewMysqlDb(dbName, host string, port int, username, password, config string) (*MysqlDb, error)

func (*MysqlDb) AutoMigrate

func (db *MysqlDb) AutoMigrate(dst ...interface{}) error

func (*MysqlDb) Db

func (db *MysqlDb) Db(model interface{}) *gorm.DB

func (*MysqlDb) DebugDb

func (db *MysqlDb) DebugDb() *gorm.DB

func (*MysqlDb) SetDebug

func (db *MysqlDb) SetDebug()

type MysqlDbConfig

type MysqlDbConfig struct {
	GormConfig *gorm.Config
	Config     mysql.Config
}

type MysqlSession

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

func NewMysqlSession

func NewMysqlSession(dbName, host string, port int, username, password, config string) (*MysqlSession, error)

type RedisConfig

type RedisConfig struct {
	Opt *redis.Options
}

type RedisDb

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

func NewRedisDb

func NewRedisDb(ctx context.Context, opt *redis.Options) (*RedisDb, error)

func (*RedisDb) BLPop

func (r *RedisDb) BLPop(ctx context.Context, timeout time.Duration, keys ...string) ([]string, error)

func (*RedisDb) Client

func (r *RedisDb) Client() *redis.Client

func (*RedisDb) Close

func (r *RedisDb) Close() error

func (*RedisDb) Del

func (r *RedisDb) Del(ctx context.Context, keys ...string) (int64, error)

func (*RedisDb) Eval

func (r *RedisDb) Eval(ctx context.Context, script string, keys []string, args ...interface{}) (interface{}, error)

func (*RedisDb) Exists

func (r *RedisDb) Exists(ctx context.Context, keys ...string) (int64, error)

func (*RedisDb) Expire

func (r *RedisDb) Expire(ctx context.Context, key string, expire time.Duration) error

func (*RedisDb) GetByte

func (r *RedisDb) GetByte(ctx context.Context, key string) ([]byte, error)

func (*RedisDb) GetFloat

func (r *RedisDb) GetFloat(ctx context.Context, key string) (float64, error)

func (*RedisDb) GetInt

func (r *RedisDb) GetInt(ctx context.Context, key string) (int, error)

func (*RedisDb) GetScan

func (r *RedisDb) GetScan(ctx context.Context, key string, value interface{}) error

func (*RedisDb) GetString

func (r *RedisDb) GetString(ctx context.Context, key string) (string, error)

func (*RedisDb) HDel

func (r *RedisDb) HDel(ctx context.Context, key string, fields ...string) (int64, error)

func (*RedisDb) HGet

func (r *RedisDb) HGet(ctx context.Context, key, field string) (string, error)

func (*RedisDb) HGetAll

func (r *RedisDb) HGetAll(ctx context.Context, key string) (map[string]string, error)

func (*RedisDb) HIncrBy

func (r *RedisDb) HIncrBy(ctx context.Context, key, field string, value int64) (int64, error)

func (*RedisDb) HIncrByFloat

func (r *RedisDb) HIncrByFloat(ctx context.Context, key, field string, value float64) (float64, error)

func (*RedisDb) HMGet

func (r *RedisDb) HMGet(ctx context.Context, key string, fields []string) ([]interface{}, error)

func (*RedisDb) HSet

func (r *RedisDb) HSet(ctx context.Context, key string, values ...interface{}) (int64, error)

func (*RedisDb) Incr

func (r *RedisDb) Incr(ctx context.Context, key string) (int64, error)

func (*RedisDb) IncrBy

func (r *RedisDb) IncrBy(ctx context.Context, key string, value int64) (int64, error)

func (*RedisDb) IncrByFloat

func (r *RedisDb) IncrByFloat(ctx context.Context, key string, value float64) (float64, error)

func (*RedisDb) LPop

func (r *RedisDb) LPop(ctx context.Context, key string, value interface{}) error

func (*RedisDb) LPush

func (r *RedisDb) LPush(ctx context.Context, key string, values ...interface{}) (int64, error)

func (*RedisDb) PSubscribe

func (r *RedisDb) PSubscribe(ctx context.Context, channels ...string) *redis.PubSub

func (*RedisDb) Ping

func (r *RedisDb) Ping(ctx context.Context) error

func (*RedisDb) Publish

func (r *RedisDb) Publish(ctx context.Context, channel string, message interface{}) error

func (*RedisDb) RPop

func (r *RedisDb) RPop(ctx context.Context, key string, value interface{}) error

func (*RedisDb) RPush

func (r *RedisDb) RPush(ctx context.Context, key string, values ...interface{}) (int64, error)

func (*RedisDb) Set

func (r *RedisDb) Set(ctx context.Context, key string, value interface{}, expire time.Duration) *redis.StatusCmd

func (*RedisDb) SetLogger

func (r *RedisDb) SetLogger(log *logger.Logger)

func (*RedisDb) SetNX

func (r *RedisDb) SetNX(ctx context.Context, key string, value interface{}, expiration time.Duration) (bool, error)

func (*RedisDb) Subscribe

func (r *RedisDb) Subscribe(ctx context.Context) *redis.PubSub

func (*RedisDb) ZAdd

func (r *RedisDb) ZAdd(ctx context.Context, key string, members ...*redis.Z) (int64, error)

func (*RedisDb) ZCard

func (r *RedisDb) ZCard(ctx context.Context, key string) (int64, error)

func (*RedisDb) ZRange

func (r *RedisDb) ZRange(ctx context.Context, key string, min, max int64) ([]string, error)

func (*RedisDb) ZRangeByScore

func (r *RedisDb) ZRangeByScore(ctx context.Context, key string, min, max int64, offset, count int64) ([]string, error)

func (*RedisDb) ZRemRangeByRank

func (r *RedisDb) ZRemRangeByRank(ctx context.Context, key string, start, stop int64) (int64, error)

func (*RedisDb) ZRemRangeByScore

func (r *RedisDb) ZRemRangeByScore(ctx context.Context, key string, min, max int64) (int64, error)

type RedisSession

type RedisSession struct {
	Id int
	// contains filtered or unexported fields
}

func NewRedisSession

func NewRedisSession(opt *redis.Options) (*RedisSession, error)

func (*RedisSession) Db

func (db *RedisSession) Db() *RedisDb

func (*RedisSession) Ping

func (db *RedisSession) Ping(ctx context.Context) error

Jump to

Keyboard shortcuts

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