Documentation ¶
Index ¶
- func InjectCreatePool(fun CreateConnectFunc)
- func TransSql(sql string, whereParams ...interface{}) string
- type Aliaser
- type CreateConnectFunc
- type DB
- func (db *DB) BeginTransaction()
- func (db *DB) Commit()
- func (db *DB) Desc(tableName string) lib.Columns
- func (db *DB) Exec(sql string) int64
- func (db *DB) IsExist(tableName string) bool
- func (db *DB) Query(sql string, whereParams ...interface{}) lib.SqlRows
- func (db *DB) Rollback()
- func (db *DB) SetDB(connectName, databaseName string) DBer
- func (db *DB) SetPool(pool MsSqlPooler) DBPool
- func (db *DB) ShowDatabases() []string
- func (db *DB) ShowTables() []string
- type DBConfig
- type DBPool
- type DBer
- type Fielder
- type GroupByer
- type Havinger
- type Joiner
- type Limit
- type Limiter
- type Model
- func (m *Model) Alias(name string) Aliaser
- func (m *Model) AndHaving(field string, value interface{}) Havinger
- func (m *Model) AndHavingIn(field string, value interface{}) Havinger
- func (m *Model) AndHavingNotIn(field string, value interface{}) Havinger
- func (m *Model) AndHavingRaw(having string) Havinger
- func (m *Model) AndHavingSymbol(field, symbol string, value interface{}) Havinger
- func (m *Model) AndOn(field string, value interface{}) Oner
- func (m *Model) AndOnIn(field string, value interface{}) Oner
- func (m *Model) AndOnNotIn(field string, value interface{}) Oner
- func (m *Model) AndOnRaw(on string) Oner
- func (m *Model) AndOnSymbol(field, symbol string, value interface{}) Oner
- func (m *Model) AndWhere(field string, value interface{}) Wherer
- func (m *Model) AndWhereIn(field string, value interface{}) Wherer
- func (m *Model) AndWhereNotIn(field string, value interface{}) Wherer
- func (m *Model) AndWhereRaw(where string) Wherer
- func (m *Model) AndWhereSymbol(field, symbol string, value interface{}) Wherer
- func (m *Model) Count() int64
- func (m *Model) CountByClear(isClear bool) int64
- func (m *Model) Create(row lib.SqlIn) int64
- func (m *Model) DB() DBer
- func (m *Model) Delete() int64
- func (m *Model) Drop() int64
- func (m *Model) Fields(fields ...string) Fielder
- func (m *Model) Find() lib.SqlRow
- func (m *Model) Get() lib.SqlRows
- func (m *Model) GetByClear(isClear bool) lib.SqlRows
- func (m *Model) GetLastSql() string
- func (m *Model) GetModelSql() (string, []interface{})
- func (m *Model) GetSqlInfo() (string, []interface{})
- func (m *Model) GroupBy(field ...string) GroupByer
- func (m *Model) Having(field string, value interface{}) Havinger
- func (m *Model) HavingIn(field string, value interface{}) Havinger
- func (m *Model) HavingNotIn(field string, value interface{}) Havinger
- func (m *Model) HavingRaw(having string) Havinger
- func (m *Model) HavingSymbol(field, symbol string, value interface{}) Havinger
- func (m *Model) Init(dbName, tableName string) Modeler
- func (m *Model) InitByConnectName(connectName, dbName, tableName string) Modeler
- func (m *Model) Insert(row lib.SqlIn) int64
- func (m *Model) Join(tableName string) Joiner
- func (m *Model) LeftJoin(tableName string) Joiner
- func (m *Model) Limit(offset, count int) Limiter
- func (m *Model) On(field string, value interface{}) Oner
- func (m *Model) OnIn(field string, value interface{}) Oner
- func (m *Model) OnNotIn(field string, value interface{}) Oner
- func (m *Model) OnRaw(on string) Oner
- func (m *Model) OnSymbol(field, symbol string, value interface{}) Oner
- func (m *Model) OrHaving(field string, value interface{}) Havinger
- func (m *Model) OrHavingIn(field string, value interface{}) Havinger
- func (m *Model) OrHavingNotIn(field string, value interface{}) Havinger
- func (m *Model) OrHavingRaw(having string) Havinger
- func (m *Model) OrHavingSymbol(field, symbol string, value interface{}) Havinger
- func (m *Model) OrOn(field string, value interface{}) Oner
- func (m *Model) OrOnIn(field string, value interface{}) Oner
- func (m *Model) OrOnNotIn(field string, value interface{}) Oner
- func (m *Model) OrOnRaw(on string) Oner
- func (m *Model) OrOnSymbol(field, symbol string, value interface{}) Oner
- func (m *Model) OrWhere(field string, value interface{}) Wherer
- func (m *Model) OrWhereIn(field string, value interface{}) Wherer
- func (m *Model) OrWhereNotIn(field string, value interface{}) Wherer
- func (m *Model) OrWhereRaw(where string) Wherer
- func (m *Model) OrWhereSymbol(field, symbol string, value interface{}) Wherer
- func (m *Model) OrderBy(orderBy string) OrderByer
- func (m *Model) Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow)
- func (m *Model) RightJoin(tableName string) Joiner
- func (m *Model) Truncate() int64
- func (m *Model) Union(model Modeler) Unioner
- func (m *Model) Update(data lib.SqlIn) int64
- func (m *Model) Where(field string, value interface{}) Wherer
- func (m *Model) WhereIn(field string, value interface{}) Wherer
- func (m *Model) WhereNotIn(field string, value interface{}) Wherer
- func (m *Model) WhereRaw(where string) Wherer
- func (m *Model) WhereSymbol(field, symbol string, value interface{}) Wherer
- type Modeler
- type MsSqlConnect
- type MsSqlPool
- func (m *MsSqlPool) AddConnect(connect MsSqlConnect)
- func (m *MsSqlPool) AddConnects(connects []MsSqlConnect)
- func (m *MsSqlPool) BeginTx(connectName string)
- func (m *MsSqlPool) Close()
- func (m *MsSqlPool) EndTx(connectName string)
- func (m *MsSqlPool) GetDB(connectName string) *sql.DB
- func (m *MsSqlPool) GetIncludeReadDB(connectName string) *sql.DB
- func (m *MsSqlPool) GetTx(connectName string) *sql.Tx
- func (m *MsSqlPool) Init(connects []MsSqlConnect)
- func (m *MsSqlPool) IsTransaction(connectName string) bool
- func (m *MsSqlPool) SetTx(connectName string, tx *sql.Tx)
- type MsSqlPooler
- type Oner
- type OrderByer
- type Table
- func (t *Table) Delete(onParams []interface{}, where string, whereParams ...interface{}) int64
- func (t *Table) Drop() int64
- func (t *Table) GetDB() *DB
- func (t *Table) GetLastSql() string
- func (t *Table) GetSqlInfo() (string, []interface{})
- func (t *Table) Insert(row lib.SqlIn) int64
- func (t *Table) Select(fields string, where string, whereParams ...interface{}) lib.SqlRows
- func (t *Table) SelectByHasWhere(fields string, where string, hasWhere bool, page *Limit, ...) lib.SqlRows
- func (t *Table) SetDB(db *DB)
- func (t *Table) Truncate() int64
- func (t *Table) Update(row lib.SqlIn, onParams []interface{}, where string, ...) int64
- type Tabler
- type Unioner
- type Wherer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InjectCreatePool ¶
func InjectCreatePool(fun CreateConnectFunc)
InjectCreatePool 注入连接池的创建过程 connect 连接MsSql配置 fun 回调函数返回MsSql连接配置
Types ¶
type Aliaser ¶
type Aliaser interface { Join(tableName string) Joiner LeftJoin(tableName string) Joiner RightJoin(tableName string) Joiner Union(model Modeler) Unioner Where(field string, value interface{}) Wherer WhereRaw(where string) Wherer WhereSymbol(field, symbol string, value interface{}) Wherer WhereIn(field string, value interface{}) Wherer WhereNotIn(field string, value interface{}) Wherer GroupBy(field ...string) GroupByer Count() int64 Get() lib.SqlRows Find() lib.SqlRow OrderBy(orderBy string) OrderByer Limit(offset, count int) Limiter Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) Update(data lib.SqlIn) int64 }
Aliaser 另外取名接口
type DBConfig ¶
type DBConfig struct { Name string `json:"name"` DatabaseName string `json:"databaseName"` UserName string `json:"userName"` Password string `json:"password"` Host string `json:"host"` Port string `json:"port"` Charset string `json:"charset"` MaxOpenConns int `json:"maxOpenConns"` MaxIdleConns int `json:"maxIdleConns"` MaxLifetime int `json:"maxLifetime"` Prefix string `json:"prefix"` Suffix string `json:"suffix"` }
DBConfig 从库配置数据
type DBer ¶
type DBer interface { BeginTransaction() Commit() Rollback() Exec(sql string) int64 Query(sql string, whereParams ...interface{}) lib.SqlRows Desc(tableName string) lib.Columns IsExist(tableName string) bool ShowTables() []string ShowDatabases() []string }
DBer 数据库接口
type Fielder ¶
type Fielder interface { Alias(name string) Aliaser Join(tableName string) Joiner LeftJoin(tableName string) Joiner RightJoin(tableName string) Joiner Union(model Modeler) Unioner Where(field string, value interface{}) Wherer WhereRaw(where string) Wherer WhereSymbol(field, symbol string, value interface{}) Wherer WhereIn(field string, value interface{}) Wherer WhereNotIn(field string, value interface{}) Wherer GroupBy(field ...string) GroupByer Count() int64 Get() lib.SqlRows Find() lib.SqlRow OrderBy(orderBy string) OrderByer Limit(offset, count int) Limiter Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) }
Fielder 字段暴露出去的接口
type GroupByer ¶
type GroupByer interface { Having(field string, value interface{}) Havinger HavingRaw(having string) Havinger HavingSymbol(field, symbol string, value interface{}) Havinger HavingIn(field string, value interface{}) Havinger HavingNotIn(field string, value interface{}) Havinger Get() lib.SqlRows Find() lib.SqlRow Count() int64 OrderBy(orderBy string) OrderByer Limit(offset, count int) Limiter Union(model Modeler) Unioner Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) }
GroupByer 分组接口
type Havinger ¶
type Havinger interface { AndHaving(field string, value interface{}) Havinger AndHavingRaw(having string) Havinger AndHavingSymbol(field, symbol string, value interface{}) Havinger AndHavingIn(field string, value interface{}) Havinger AndHavingNotIn(field string, value interface{}) Havinger OrHaving(field string, value interface{}) Havinger OrHavingRaw(having string) Havinger OrHavingSymbol(field, symbol string, value interface{}) Havinger OrHavingIn(field string, value interface{}) Havinger OrHavingNotIn(field string, value interface{}) Havinger Get() lib.SqlRows Find() lib.SqlRow Count() int64 OrderBy(orderBy string) OrderByer Limit(offset, count int) Limiter Union(model Modeler) Unioner Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) }
Havinger having条件
type Joiner ¶
type Joiner interface { On(field string, value interface{}) Oner OnRaw(on string) Oner OnSymbol(field, symbol string, value interface{}) Oner OnIn(field string, value interface{}) Oner OnNotIn(field string, value interface{}) Oner }
Joiner 连接接口
type Model ¶
type Model struct { PriKey string SoftDelete bool DeleteName string // contains filtered or unexported fields }
Model 模型
func (*Model) AndHavingIn ¶
AndHavingIn having条件
func (*Model) AndHavingNotIn ¶
AndHavingNotIn having条件
func (*Model) AndHavingRaw ¶
AndHavingRaw having条件
func (*Model) AndHavingSymbol ¶
AndHavingSymbol having条件
func (*Model) AndOnNotIn ¶
AndOnNotIn Join 条件on
func (*Model) AndOnSymbol ¶
AndOnSymbol Join 条件on
func (*Model) AndWhereIn ¶
AndWhereIn where条件
func (*Model) AndWhereNotIn ¶
AndWhereNotIn where条件
func (*Model) AndWhereSymbol ¶
AndWhereSymbol where条件
func (*Model) GetSqlInfo ¶
GetSqlInfo 获得最后执行的sql
func (*Model) HavingNotIn ¶
HavingNotIn having条件
func (*Model) HavingSymbol ¶
HavingSymbol having条件
func (*Model) InitByConnectName ¶
Init 初始化
func (*Model) OrHavingIn ¶
OrHavingIn having条件
func (*Model) OrHavingNotIn ¶
OrHavingNotIn having条件
func (*Model) OrHavingRaw ¶
OrHavingRaw having条件
func (*Model) OrHavingSymbol ¶
OrHavingSymbol having条件
func (*Model) OrOnSymbol ¶
OrOnSymbol Join 条件on
func (*Model) OrWhereNotIn ¶
OrWhereNotIn where条件
func (*Model) OrWhereSymbol ¶
OrWhereSymbol where条件
func (*Model) WhereNotIn ¶
WhereNotIn where条件
func (*Model) WhereSymbol ¶
WhereSymbol where条件
type Modeler ¶
type Modeler interface { Fields(fields ...string) Fielder Count() int64 GetLastSql() string GetSqlInfo() (string, []interface{}) GetModelSql() (string, []interface{}) Alias(name string) Aliaser Join(tableName string) Joiner LeftJoin(tableName string) Joiner RightJoin(tableName string) Joiner Union(model Modeler) Unioner Where(field string, value interface{}) Wherer WhereRaw(where string) Wherer WhereSymbol(field, symbol string, value interface{}) Wherer WhereIn(field string, value interface{}) Wherer WhereNotIn(field string, value interface{}) Wherer GroupBy(field ...string) GroupByer Get() lib.SqlRows Find() lib.SqlRow OrderBy(orderBy string) OrderByer Limit(offset, count int) Limiter Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) Update(data lib.SqlIn) int64 Insert(row lib.SqlIn) int64 Create(row lib.SqlIn) int64 Drop() int64 Truncate() int64 Delete() int64 DB() DBer }
Modeler 模型接口
func NewModelByConnectName ¶
NewModelByConnectName 新建一个模型
type MsSqlConnect ¶
MsSqlConnect mssql连接配置数据
func (MsSqlConnect) String ¶
func (m MsSqlConnect) String() string
type MsSqlPool ¶
type MsSqlPool struct {
// contains filtered or unexported fields
}
MsSqlPool 全局连接池
func (*MsSqlPool) AddConnects ¶
func (m *MsSqlPool) AddConnects(connects []MsSqlConnect)
AddConnects 添加多个连接
func (*MsSqlPool) GetIncludeReadDB ¶
GetIncludeReadDB 取出只读数据库连接
func (*MsSqlPool) IsTransaction ¶
IsTransaction 是否开启事务
type MsSqlPooler ¶
type MsSqlPooler interface { GetDB(connectName string) *sql.DB GetIncludeReadDB(connectName string) *sql.DB SetTx(connectName string, tx *sql.Tx) GetTx(connectName string) *sql.Tx BeginTx(connectName string) EndTx(connectName string) IsTransaction(connectName string) bool Close() Init(connect []MsSqlConnect) AddConnect(connect MsSqlConnect) AddConnects(connects []MsSqlConnect) }
MysqlPooler 全局连接池接口
type Oner ¶
type Oner interface { OrOn(field string, value interface{}) Oner OrOnRaw(on string) Oner OrOnSymbol(field, symbol string, value interface{}) Oner OrOnIn(field string, value interface{}) Oner OrOnNotIn(field string, value interface{}) Oner AndOn(field string, value interface{}) Oner AndOnRaw(on string) Oner AndOnSymbol(field, symbol string, value interface{}) Oner AndOnIn(field string, value interface{}) Oner AndOnNotIn(field string, value interface{}) Oner Where(field string, value interface{}) Wherer WhereRaw(where string) Wherer WhereSymbol(field, symbol string, value interface{}) Wherer WhereIn(field string, value interface{}) Wherer WhereNotIn(field string, value interface{}) Wherer Join(tableName string) Joiner LeftJoin(tableName string) Joiner RightJoin(tableName string) Joiner GroupBy(field ...string) GroupByer Count() int64 Get() lib.SqlRows Find() lib.SqlRow OrderBy(orderBy string) OrderByer Limit(offset, count int) Limiter Union(model Modeler) Unioner Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) Update(data lib.SqlIn) int64 }
Oner on连接条件
type OrderByer ¶
type OrderByer interface { Get() lib.SqlRows Find() lib.SqlRow Limit(offset, count int) Limiter Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) }
OrderByer 排序
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table 操作表
type Tabler ¶
type Tabler interface { SetDB(db *DB) GetDB() *DB Insert(row lib.SqlIn) int64 Drop() int64 Truncate() int64 Delete(onParams []interface{}, where string, whereParams ...interface{}) int64 Update(row lib.SqlIn, onParams []interface{}, where string, whereParams ...interface{}) int64 SelectByHasWhere(fields string, where string, hasWhere bool, page *Limit, whereParams ...interface{}) lib.SqlRows Select(fields string, where string, whereParams ...interface{}) lib.SqlRows GetLastSql() string GetSqlInfo() (string, []interface{}) }
Tabler 表操作接口
type Unioner ¶
type Unioner interface { Count() int64 Get() lib.SqlRows Find() lib.SqlRow OrderBy(orderBy string) OrderByer Limit(offset, count int) Limiter Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) }
Unioner
type Wherer ¶
type Wherer interface { AndWhere(field string, value interface{}) Wherer AndWhereRaw(where string) Wherer AndWhereSymbol(field, symbol string, value interface{}) Wherer AndWhereIn(field string, value interface{}) Wherer AndWhereNotIn(field string, value interface{}) Wherer OrWhere(field string, value interface{}) Wherer OrWhereRaw(where string) Wherer OrWhereSymbol(field, symbol string, value interface{}) Wherer OrWhereIn(field string, value interface{}) Wherer OrWhereNotIn(field string, value interface{}) Wherer GroupBy(field ...string) GroupByer Get() lib.SqlRows Find() lib.SqlRow Count() int64 OrderBy(orderBy string) OrderByer Limit(offset, count int) Limiter Union(model Modeler) Unioner Pager(page, pageSize int) (lib.SqlRows, lib.SqlRow) Update(data lib.SqlIn) int64 Delete() int64 }
Wherer 条件接口