Documentation ¶
Index ¶
- Constants
- Variables
- func GetValue(obj interface{}, elem *FieldElem) (interface{}, error)
- func Model(v interface{}) func() interface{}
- func ModelDriver(objects ...sqlc.Object) error
- func OutDest(rows *sql.Rows, flen int) ([][][]byte, error)
- func SetValue(obj interface{}, elem *FieldElem, b []byte) error
- type CountResult
- type DBConfig
- type DBManager
- func (self *DBManager) BuilGroupBy(cnd *sqlc.Cnd) string
- func (self *DBManager) BuilSortBy(cnd *sqlc.Cnd) string
- func (self *DBManager) BuildCondKey(cnd *sqlc.Cnd, key string) []byte
- func (self *DBManager) BuildPagination(cnd *sqlc.Cnd, sql string, values []interface{}) (string, error)
- func (self *DBManager) BuildWhereCase(cnd *sqlc.Cnd) (*bytes.Buffer, []interface{})
- func (self *DBManager) Close() error
- func (self *DBManager) Count(cnd *sqlc.Cnd) (int64, error)
- func (self *DBManager) Delete(datas ...sqlc.Object) error
- func (self *DBManager) Error(data ...interface{}) error
- func (self *DBManager) FindById(data sqlc.Object) error
- func (self *DBManager) FindList(cnd *sqlc.Cnd, data interface{}) error
- func (self *DBManager) FindListComplex(cnd *sqlc.Cnd, data interface{}) error
- func (self *DBManager) FindOne(cnd *sqlc.Cnd, data sqlc.Object) error
- func (self *DBManager) FindOneComplex(cnd *sqlc.Cnd, data sqlc.Object) error
- func (self *DBManager) GetDB(option ...Option) error
- func (self *DBManager) InitConfig(input interface{}) error
- func (self *DBManager) Save(datas ...sqlc.Object) error
- func (self *DBManager) Update(datas ...sqlc.Object) error
- func (self *DBManager) UpdateByCnd(cnd *sqlc.Cnd) error
- type FieldElem
- type IDBase
- type MGOConfig
- type MGOManager
- func (self *MGOManager) Close() error
- func (self *MGOManager) Count(cnd *sqlc.Cnd) (int64, error)
- func (self *MGOManager) Delete(data ...sqlc.Object) error
- func (self *MGOManager) FindList(cnd *sqlc.Cnd, data interface{}) error
- func (self *MGOManager) FindOne(cnd *sqlc.Cnd, data sqlc.Object) error
- func (self *MGOManager) Get(option ...Option) (*MGOManager, error)
- func (self *MGOManager) GetDB(options ...Option) error
- func (self *MGOManager) GetDatabase(copySession *mgo.Session, tb string) (*mgo.Collection, error)
- func (self *MGOManager) InitConfig(input ...MGOConfig) error
- func (self *MGOManager) InitConfigAndCache(manager cache.Cache, input ...MGOConfig) error
- func (self *MGOManager) Save(data ...sqlc.Object) error
- func (self *MGOManager) Update(data ...sqlc.Object) error
- func (self *MGOManager) UpdateByCnd(cnd *sqlc.Cnd) error
- type MGOSyncData
- type MdlDriver
- type MysqlConfig
- type MysqlManager
- type Option
- type RDBManager
- func (self *RDBManager) BuilGroupBy(cnd *sqlc.Cnd) string
- func (self *RDBManager) BuilSortBy(cnd *sqlc.Cnd) string
- func (self *RDBManager) BuildCondKey(cnd *sqlc.Cnd, key string) []byte
- func (self *RDBManager) BuildPagination(cnd *sqlc.Cnd, sqlbuf string, values []interface{}) (string, error)
- func (self *RDBManager) BuildWhereCase(cnd *sqlc.Cnd) (*bytes.Buffer, []interface{})
- func (self *RDBManager) Close() error
- func (self *RDBManager) Count(cnd *sqlc.Cnd) (int64, error)
- func (self *RDBManager) Delete(data ...sqlc.Object) error
- func (self *RDBManager) FindById(data sqlc.Object) error
- func (self *RDBManager) FindList(cnd *sqlc.Cnd, data interface{}) error
- func (self *RDBManager) FindListComplex(cnd *sqlc.Cnd, data interface{}) error
- func (self *RDBManager) FindOne(cnd *sqlc.Cnd, data sqlc.Object) error
- func (self *RDBManager) FindOneComplex(cnd *sqlc.Cnd, data sqlc.Object) error
- func (self *RDBManager) GetDB(options ...Option) error
- func (self *RDBManager) Save(data ...sqlc.Object) error
- func (self *RDBManager) Update(data ...sqlc.Object) error
- func (self *RDBManager) UpdateByCnd(cnd *sqlc.Cnd) error
Constants ¶
View Source
const ( SAVE = 1 UPDATE = 2 DELETE = 3 UPDATE_BY_CND = 4 )
View Source
const ( JID = "id" BID = "_id" COUNT_BY = "COUNT_BY" )
Variables ¶
View Source
var ( ZERO = int64(0) TRUE = true FALSE = false )
Functions ¶
func ModelDriver ¶
Types ¶
type CountResult ¶
type CountResult struct {
Total int64 `bson:"COUNT_BY"`
}
type DBConfig ¶
type DBConfig struct { Option Host string // 地址IP Port int // 数据库端口 Username string // 账号 Password string // 密码 SlowQuery int64 // 0.不开启筛选 >0开启筛选查询 毫秒 SlowLogPath string // 慢查询写入地址 }
数据库配置
type DBManager ¶
type DBManager struct { Option CacheManager cache.Cache // 缓存管理器 MGOSyncData []*MGOSyncData // 同步数据对象 Errors []error // 错误异常记录 }
数据库管理器
func (*DBManager) BuildCondKey ¶
func (*DBManager) BuildPagination ¶
func (*DBManager) BuildWhereCase ¶
func (*DBManager) FindListComplex ¶
func (*DBManager) FindOneComplex ¶
func (*DBManager) InitConfig ¶
type IDBase ¶
type IDBase interface { // 初始化数据库配置 InitConfig(input interface{}) error // 获取数据库管理器 GetDB(option ...Option) error // 保存数据 Save(datas ...sqlc.Object) error // 更新数据 Update(datas ...sqlc.Object) error // 按条件更新数据 UpdateByCnd(cnd *sqlc.Cnd) error // 删除数据 Delete(datas ...sqlc.Object) error // 统计数据 Count(cnd *sqlc.Cnd) (int64, error) // 按ID查询单条数据 FindById(data sqlc.Object) error // 按条件查询单条数据 FindOne(cnd *sqlc.Cnd, data sqlc.Object) error // 按条件查询数据 FindList(cnd *sqlc.Cnd, data interface{}) error // 按复杂条件查询数据 FindOneComplex(cnd *sqlc.Cnd, data sqlc.Object) error // 按复杂条件查询数据列表 FindListComplex(cnd *sqlc.Cnd, data interface{}) error // 构建数据表别名 BuildCondKey(cnd *sqlc.Cnd, key string) []byte // 构建逻辑条件 BuildWhereCase(cnd *sqlc.Cnd) (*bytes.Buffer, []interface{}) // 构建分组条件 BuilGroupBy(cnd *sqlc.Cnd) string // 构建排序条件 BuilSortBy(cnd *sqlc.Cnd) string // 构建分页条件 BuildPagination(cnd *sqlc.Cnd, sql string, values []interface{}) (string, error) // 数据库操作缓存异常 Error(data ...interface{}) error }
orm数据库接口
type MGOConfig ¶
type MGOConfig struct { DBConfig Addrs []string Direct bool ConnectTimeout int64 SocketTimeout int64 Database string Username string Password string PoolLimit int ConnectionURI string }
数据库配置
type MGOManager ¶
数据库管理器
func NewMongo ¶
func NewMongo(option ...Option) (*MGOManager, error)
func (*MGOManager) Close ¶
func (self *MGOManager) Close() error
func (*MGOManager) FindList ¶
func (self *MGOManager) FindList(cnd *sqlc.Cnd, data interface{}) error
查询多条数据
func (*MGOManager) Get ¶
func (self *MGOManager) Get(option ...Option) (*MGOManager, error)
func (*MGOManager) GetDB ¶
func (self *MGOManager) GetDB(options ...Option) error
func (*MGOManager) GetDatabase ¶
func (self *MGOManager) GetDatabase(copySession *mgo.Session, tb string) (*mgo.Collection, error)
获取mongo的数据库连接
func (*MGOManager) InitConfig ¶
func (self *MGOManager) InitConfig(input ...MGOConfig) error
func (*MGOManager) InitConfigAndCache ¶
func (self *MGOManager) InitConfigAndCache(manager cache.Cache, input ...MGOConfig) error
type MGOSyncData ¶
type MysqlConfig ¶
type MysqlConfig struct { DBConfig MaxIdleConns int MaxOpenConns int ConnMaxLifetime int ConnMaxIdleTime int }
mysql配置参数
type MysqlManager ¶
type MysqlManager struct {
RDBManager
}
mysql连接管理器
func NewMysql ¶
func NewMysql(option ...Option) (*MysqlManager, error)
func (*MysqlManager) Get ¶
func (self *MysqlManager) Get(option ...Option) (*MysqlManager, error)
func (*MysqlManager) InitConfig ¶
func (self *MysqlManager) InitConfig(input ...MysqlConfig) error
func (*MysqlManager) InitConfigAndCache ¶
func (self *MysqlManager) InitConfigAndCache(manager cache.Cache, input ...MysqlConfig) error
type Option ¶
type Option struct { DsName string // 数据源,分库时使用 Database string // 数据库名称 OpenTx bool // 是否开启事务 true.是 false.否 MongoSync bool // 是否自动同步mongo数据库写入 Timeout int64 // 请求超时设置/毫秒,默认10000 SlowQuery int64 // 0.不开启筛选 >0开启筛选查询 毫秒 SlowLogPath string // 慢查询写入地址 }
数据选项
type RDBManager ¶
关系数据库连接管理器
func (*RDBManager) BuildCondKey ¶
func (self *RDBManager) BuildCondKey(cnd *sqlc.Cnd, key string) []byte
func (*RDBManager) BuildPagination ¶
func (self *RDBManager) BuildPagination(cnd *sqlc.Cnd, sqlbuf string, values []interface{}) (string, error)
构建分页命令
func (*RDBManager) BuildWhereCase ¶
func (self *RDBManager) BuildWhereCase(cnd *sqlc.Cnd) (*bytes.Buffer, []interface{})
构建where条件
func (*RDBManager) Close ¶
func (self *RDBManager) Close() error
func (*RDBManager) FindList ¶
func (self *RDBManager) FindList(cnd *sqlc.Cnd, data interface{}) error
func (*RDBManager) FindListComplex ¶
func (self *RDBManager) FindListComplex(cnd *sqlc.Cnd, data interface{}) error
func (*RDBManager) FindOneComplex ¶
func (*RDBManager) GetDB ¶
func (self *RDBManager) GetDB(options ...Option) error
func (*RDBManager) UpdateByCnd ¶
func (self *RDBManager) UpdateByCnd(cnd *sqlc.Cnd) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.