db

package
v0.0.0-...-b87ab60 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitMongoClient

func InitMongoClient(cfg *cfgargs.SrvConfig) error

func InitRedisClient

func InitRedisClient(cfg *cfgargs.SrvConfig)

func IsNoDocumentError

func IsNoDocumentError(err error) bool

IsNoDocumentError ...

func IsNotExistError

func IsNotExistError(err error) bool

IsNotExistError 判断error是否为redis.Nil

Types

type MongoClient

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

MongoClient ..

func GetLastMongoClient

func GetLastMongoClient() *MongoClient

GetLastMongoClient ...

func NewMongoClient

func NewMongoClient(host, port, db, user, password string, panicIfDisconnect bool) (mongoClient *MongoClient, err error)

NewMongoClient ...

func (*MongoClient) DeleteMany

func (m *MongoClient) DeleteMany(collection string, filter interface{},
	opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteMany ...

func (*MongoClient) DeleteOne

func (m *MongoClient) DeleteOne(collection string, filter interface{},
	opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteOne ...

func (*MongoClient) Find

func (m *MongoClient) Find(collection string, val, filter interface{},
	opts ...*options.FindOptions) error

Find ...

func (*MongoClient) FindOne

func (m *MongoClient) FindOne(collection string, val, filter interface{},
	opts ...*options.FindOneOptions) error

FindOne ...

func (*MongoClient) FindOneAndDelete

func (m *MongoClient) FindOneAndDelete(collection string, val, filter interface{},
	opts ...*options.FindOneAndDeleteOptions) error

FindOneAndDelete ...

func (*MongoClient) FindOneAndReplace

func (m *MongoClient) FindOneAndReplace(collection string, val, filter,
	replacement interface{}, opts ...*options.FindOneAndReplaceOptions) error

FindOneAndReplace ...

func (*MongoClient) FindOneAndUpdate

func (m *MongoClient) FindOneAndUpdate(collection string, val, filter,
	update interface{}, opts ...*options.FindOneAndUpdateOptions) error

FindOneAndUpdate ...

func (*MongoClient) GetAllCollectionNames

func (m *MongoClient) GetAllCollectionNames() ([]string, error)

GetAllCollectionNames ...

func (*MongoClient) GetAllDatabaseNames

func (m *MongoClient) GetAllDatabaseNames() ([]string, error)

GetAllDatabaseNames ...

func (*MongoClient) GetCollectionHandle

func (m *MongoClient) GetCollectionHandle(collection string) *mongo.Collection

GetCollectionHandle ...

func (*MongoClient) InsertMany

func (m *MongoClient) InsertMany(collection string, documents []interface{},
	opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

InsertMany ...

func (*MongoClient) InsertOne

func (m *MongoClient) InsertOne(collection string, document interface{},
	opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

InsertOne ...

func (*MongoClient) ReplaceOne

func (m *MongoClient) ReplaceOne(collection string, filter interface{},
	replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

ReplaceOne ...

func (*MongoClient) UpdateByID

func (m *MongoClient) UpdateByID(collection string, id interface{}, update interface{},
	opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateByID ...

func (*MongoClient) UpdateMany

func (m *MongoClient) UpdateMany(collection string, filter interface{}, update interface{},
	opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateMany ...

func (*MongoClient) UpdateOne

func (m *MongoClient) UpdateOne(collection string, filter, update interface{},
	opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateOne ...

type RedisClient

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

RedisClient ...

func GetLastRedisClient

func GetLastRedisClient() *RedisClient

GetLastRedisClient ...

func NewRedisClient

func NewRedisClient(addr string, password string, db int, panicIfDisconnect bool) *RedisClient

NewRedisClient ...

func (*RedisClient) DelOne

func (r *RedisClient) DelOne(key string) (result int64, err error)

DelOne ...

func (*RedisClient) Expire

func (r *RedisClient) Expire(key string, expiration time.Duration) (result bool, err error)

Expire ...

func (*RedisClient) Get

func (r *RedisClient) Get(key string) (val string, err error)

Get Batch Get

func (*RedisClient) GetOne

func (r *RedisClient) GetOne(key string) (string, error)

GetOne ...

func (*RedisClient) HDel

func (r *RedisClient) HDel(key string, fields ...string) (int64, error)

HDel ...

func (*RedisClient) HGet

func (r *RedisClient) HGet(key string, field string) (string, error)

HGet ...

func (*RedisClient) HGetAll

func (r *RedisClient) HGetAll(key string) (map[string]string, error)

HGetAll ...

func (*RedisClient) HKeys

func (r *RedisClient) HKeys(key string) ([]string, error)

HKeys ...

func (*RedisClient) HSet

func (r *RedisClient) HSet(key string, field string, val interface{}) (int64, error)

HSet ...

func (*RedisClient) Incr

func (r *RedisClient) Incr(key string) (result int64, err error)

Incr ...

func (*RedisClient) Keys

func (r *RedisClient) Keys(pattern string) (vals []string, err error)

Keys FuzzyQuery

func (*RedisClient) LLen

func (r *RedisClient) LLen(key string) (result int64, err error)

LLen ...

func (*RedisClient) LPush

func (r *RedisClient) LPush(key string, val string) (result int64, err error)

LPush ...

func (*RedisClient) LRange

func (r *RedisClient) LRange(key string, start int64, end int64) (result []string, err error)

LRange ...

func (*RedisClient) LTrim

func (r *RedisClient) LTrim(key string, start int64, end int64) (result string, err error)

LTrim ...

func (*RedisClient) MGet

func (r *RedisClient) MGet(keys []string) (vals []interface{}, err error)

MGet ...

func (*RedisClient) MSet

func (r *RedisClient) MSet(vals []interface{}) (string, error)

MSet Batch Set

func (*RedisClient) Publish

func (r *RedisClient) Publish(ch string, msg string) (result int64, err error)

Publish ...

func (*RedisClient) RPop

func (r *RedisClient) RPop(key string) (result string, err error)

RPop ...

func (*RedisClient) SMembers

func (r *RedisClient) SMembers(key string) (result []string, err error)

SMembers ...

func (*RedisClient) SRem

func (r *RedisClient) SRem(key string, members []interface{}) (result int64, err error)

SRem ...

func (*RedisClient) Set

func (r *RedisClient) Set(key string, val string, expire int) (result string, err error)

Set ...

func (*RedisClient) SetAdd

func (r *RedisClient) SetAdd(key string, vals []interface{}) (result int64, err error)

SetAdd ...

func (*RedisClient) SetNx

func (r *RedisClient) SetNx(key string, val string, expire int) (result bool, err error)

SetNx ...

func (*RedisClient) TTL

func (r *RedisClient) TTL(key string) (result time.Duration, err error)

TTL ...

Jump to

Keyboard shortcuts

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