db

package module
v0.0.0-...-040153f Latest Latest
Warning

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

Go to latest
Published: May 7, 2020 License: MIT Imports: 15 Imported by: 0

README

golang mongodb and redis

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(f func(sess *mgo.Session) error) error

func GetRedis

func GetRedis() *redis.ClusterClient

func GormDB

func GormDB() *gorm.DB

custom needs with the db conn

func InitGorm

func InitGorm(addr string, maxIdle, maxOpen int) (err error)

support pg and mysql

func InitMongo

func InitMongo(hosts string, dur time.Duration, concurrent int)

func InitRedis

func InitRedis(hosts []string, pass string, poolsize int)

func IsNilReply

func IsNilReply(err error) bool

func RedisGet

func RedisGet(key string) (reply *redis.StringCmd, err error)

func RedisHGet

func RedisHGet(hKey, key string) (value string, err error)

func RedisHIncr

func RedisHIncr(hKey, key string, num int64) (err error)

func RedisHMGet

func RedisHMGet(hKey string, keys ...string) (values []interface{}, err error)

func RedisHSet

func RedisHSet(hKey, key, data string) (success bool, err error)

func RedisHash

func RedisHash(hKey string) (hash map[string]string, err error)

func RedisSet

func RedisSet(key string, data interface{}) (err error)

func SelectOne

func SelectOne(object interface{}, wheres map[string]interface{}) error

func Upsert

func Upsert(object interface{}, fields, wheres map[string]interface{}) error

common method ...

Types

type Database

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

func (*Database) Execute

func (db *Database) Execute(f func(sess *mgo.Session) error) error

func (*Database) Init

func (db *Database) Init(hosts string, dur time.Duration, concurrent int)

type ProtoByte

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

func (*ProtoByte) Bind

func (p *ProtoByte) Bind(o interface{}, key string)

func (*ProtoByte) Load

func (p *ProtoByte) Load() error

func (*ProtoByte) Save

func (p *ProtoByte) Save() error

type ProtoHash

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

func (*ProtoHash) Bind

func (p *ProtoHash) Bind(o interface{}, key string)

func (*ProtoHash) Load

func (p *ProtoHash) Load() (err error, desc string)

func (*ProtoHash) LoadField

func (p *ProtoHash) LoadField(name string) (err error)

func (*ProtoHash) LoadFields

func (p *ProtoHash) LoadFields(names ...string) (err error)

func (*ProtoHash) Save

func (p *ProtoHash) Save() (err error, desc string)

func (*ProtoHash) SaveField

func (p *ProtoHash) SaveField(name string) (err error)

Jump to

Keyboard shortcuts

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