orm

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Mongodb = map[string]interface{}{
	"mgo": createMgo,
}
View Source
var Mysql = map[string]interface{}{
	"gorm": createGorm,
	"xorm": createXorm,
}

Functions

func OrmReflect added in v1.0.5

func OrmReflect(i interface{}, addr string)

反射执行,性能较低

Types

type Db

type Db struct {
	Engine Engine
	DbBase
	// contains filtered or unexported fields
}

func (*Db) Exist added in v1.1.1

func (dbm *Db) Exist(bean interface{}) (bool, error)

func (*Db) FindBySql

func (dbm *Db) FindBySql(sql string, out interface{}) error

func (*Db) Get added in v1.0.3

func (dbm *Db) Get(query interface{}, out interface{}) error

func (*Db) GetById added in v1.0.3

func (dbm *Db) GetById(id int, out interface{}) error

func (*Db) Insert added in v1.0.3

func (dbm *Db) Insert(bean interface{}) error

func (*Db) Update added in v1.1.1

func (dbm *Db) Update(bean interface{}, condiBeans ...interface{}) (int64, error)

func (*Db) UpdateById added in v1.0.3

func (dbm *Db) UpdateById(id int, bean interface{}) error

type DbBase

type DbBase interface {
	//where() interface{}
	Get(query interface{}, out interface{}) error
	GetById(id int, out interface{}) error
	FindBySql(sql string, out interface{}) error
	Insert(bean interface{}) error
	UpdateById(id int, bean interface{}) error
}

type DbDriverName

type DbDriverName string

type DbDriverType

type DbDriverType int

type DbEngineName

type DbEngineName string
const (
	DbMysqlEngineNameXorm DbEngineName = "xorm"
	DbMysqlEngineNameGorm DbEngineName = "gorm"
	DbMongoEngineNameMgo  DbEngineName = "mgo"
)

type DbEngineType

type DbEngineType int8

orm库

const (
	DbMysqlEngineTypeXorm DbEngineType = iota
	DbMysqlEngineTypeGorm
	DbMongoEngineTypeMgo
)

type DbMongodb

type DbMongodb struct {
	Db
	// contains filtered or unexported fields
}

func GetMongodbConnByAddr

func GetMongodbConnByAddr(cf *config.Config, engine DbEngineName, addr string) *DbMongodb

通过addr链接

func GetMongodbConnByDb

func GetMongodbConnByDb(cf *config.Config, engine DbEngineName, dbname string) *DbMongodb

直接操作db

func NewDbMongo

func NewDbMongo(cf *config.Config, engine ...DbEngineName) *DbMongodb

func (*DbMongodb) Close added in v1.1.0

func (dbm *DbMongodb) Close()

func (*DbMongodb) Find added in v1.1.0

func (dbm *DbMongodb) Find(clname string, query interface{}) *mgo.Query

func (*DbMongodb) Insert added in v1.1.0

func (dbm *DbMongodb) Insert(clname string, docs ...interface{}) error

func (*DbMongodb) Update added in v1.1.0

func (dbm *DbMongodb) Update(clname string, selector interface{}, update interface{}) error

func (*DbMongodb) Upsert added in v1.1.0

func (dbm *DbMongodb) Upsert(clname string, selector interface{}, update interface{}) (interface{}, error)

type DbMysql

type DbMysql struct {
	Db
}

func GetMysqlConnByAddr

func GetMysqlConnByAddr(cf *config.Config, engine DbEngineName, addr string) *DbMysql

通过addr链接

func GetMysqlConnByDb

func GetMysqlConnByDb(cf *config.Config, engine DbEngineName, dbname string) *DbMysql

直接操作db

func NewDbMysql

func NewDbMysql(cf *config.Config, engine ...DbEngineName) *DbMysql

func (*DbMysql) Close added in v1.1.0

func (dbm *DbMysql) Close() error

type DbRedis added in v1.0.2

type DbRedis struct {
	Conn *redis.Pool
}

func NewRedis added in v1.0.2

func NewRedis(cf *config.Config) *DbRedis

func (*DbRedis) BRPop added in v1.1.0

func (m *DbRedis) BRPop(queueName string, timeout int) (data string, err error)

func (*DbRedis) Close added in v1.1.0

func (m *DbRedis) Close() (err error)

func (*DbRedis) Decr added in v1.1.2

func (m *DbRedis) Decr(setname string) (err error)

func (*DbRedis) Del added in v1.1.0

func (m *DbRedis) Del(key string) (err error)

func (*DbRedis) Get added in v1.0.2

func (m *DbRedis) Get(key string) (reply string, err error)

func (*DbRedis) GetBit added in v1.1.2

func (m *DbRedis) GetBit(key string, offset uint64) (reply int, err error)

func (*DbRedis) HDel added in v1.1.5

func (m *DbRedis) HDel(key string, field string) (reply string, err error)

func (*DbRedis) HExists added in v1.1.2

func (m *DbRedis) HExists(key string, field string) (reply bool, err error)

func (*DbRedis) HGet added in v1.1.2

func (m *DbRedis) HGet(key string, field string) (reply string, err error)

func (*DbRedis) HGetAll added in v1.1.4

func (m *DbRedis) HGetAll(key string) (reply map[string]string, err error)

func (*DbRedis) HIncr added in v1.1.4

func (m *DbRedis) HIncr(key string, field string, num int) (reply bool, err error)

func (*DbRedis) HSet added in v1.1.2

func (m *DbRedis) HSet(key string, field string, val string) (err error)

func (*DbRedis) Incr added in v1.1.1

func (m *DbRedis) Incr(setname string) (err error)

func (*DbRedis) IncrBy added in v1.1.2

func (m *DbRedis) IncrBy(setname string, member int) (err error)

func (*DbRedis) LPush added in v1.1.0

func (m *DbRedis) LPush(queueName string, key string) (err error)

func (*DbRedis) LPushBatch added in v1.1.0

func (m *DbRedis) LPushBatch(queueName string, keys []string) (err error)

list 操作

func (*DbRedis) LRange added in v1.1.3

func (m *DbRedis) LRange(key string, startIndex, endIndex int) ([]string, error)

func (*DbRedis) LRem added in v1.1.3

func (m *DbRedis) LRem(key string, count int, value string) (int, error)

func (*DbRedis) SAdd added in v1.1.2

func (m *DbRedis) SAdd(setname string, key interface{}) (err error)

func (*DbRedis) SCARD added in v1.1.2

func (m *DbRedis) SCARD(setname string) (res int, err error)

返回有序集合的基数

func (*DbRedis) SPOP added in v1.1.2

func (m *DbRedis) SPOP(setname string, num int) (data []string, err error)

func (*DbRedis) Set added in v1.0.2

func (m *DbRedis) Set(key string, val string) (err error)

func (*DbRedis) SetBit added in v1.1.2

func (m *DbRedis) SetBit(key string, offset uint64, val string) (err error)
func (m *DbRedis) Unlink(key string) (err error)

func (*DbRedis) ZAdd added in v1.1.0

func (m *DbRedis) ZAdd(setname string, value int64, key interface{}) (err error)

返回有序集合的基数

func (*DbRedis) ZCARD added in v1.1.0

func (m *DbRedis) ZCARD(setname string) (res int, err error)

返回有序集合的基数

func (*DbRedis) ZDel added in v1.1.0

func (m *DbRedis) ZDel(setname string, key string) (err error)

func (*DbRedis) ZDelBatch added in v1.1.0

func (m *DbRedis) ZDelBatch(setname string, keys []string) (err error)

func (*DbRedis) ZIncr added in v1.1.0

func (m *DbRedis) ZIncr(setname string, member string) (err error)

func (*DbRedis) ZRangeAsc added in v1.1.0

func (m *DbRedis) ZRangeAsc(setname string) (userMap []interface{}, err error)

func (*DbRedis) ZRangeDesc added in v1.1.0

func (m *DbRedis) ZRangeDesc(setname string) (userMap []interface{}, err error)

func (*DbRedis) ZRevrange added in v1.1.2

func (m *DbRedis) ZRevrange(setname string, start int, stop int) (userMap map[string]string, err error)

func (*DbRedis) ZremRangeByscore added in v1.1.0

func (m *DbRedis) ZremRangeByscore(setname string, min int64, max int64) (err error)

命令用于移除有序集中,指定分数(score)区间内的所有成员。

type Engine

type Engine struct {
	Xorm *EngineXorm
	Gorm *EngineGorm
	Mgo  *EngineMgo
}

type EngineGorm added in v1.0.5

type EngineGorm struct {
	*gorm.DB
}

type EngineMgo added in v1.0.5

type EngineMgo struct {
	*mgo.Database
}

type EngineXorm added in v1.0.5

type EngineXorm struct {
	*xorm.Engine
}

Jump to

Keyboard shortcuts

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