Documentation
¶
Overview ¶
package orm
package orm
package orm
package orm
package orm
package orm
package orm
package orm
package orm
Index ¶
- Variables
- func SetGlobalVerify(v Verify)
- func SimpleCount()
- func SimpleDeleteByWhere()
- func SimpleInsertMany()
- func SimpleInsertManySameClos()
- func SimpleInsertOne()
- func SimpleInsertOne2()
- func SimpleReplaceMany()
- func SimpleReplaceManySameClos()
- func SimpleReplaceOne()
- func SimpleToData()
- func SimpleToData2()
- func SimpleUpdateByWhere()
- func SimpleUpdateMany()
- func SimpleUpsertManySameClos()
- func SimpleUpsertOne()
- func Struct2Map(raw interface{}, excludeKey ...string) map[string]interface{}
- func TestTransSession()
- func TransSession(ctx context.Context, db *DB, f func(ctx context.Context, tx *Tx) error) (err error)
- type BaseQuery
- type Client
- type Config
- type DB
- type GroupBy
- type Having
- type Limit
- type ORM
- func (orm *ORM) ClearCache() *ORM
- func (orm *ORM) Clone() *ORM
- func (orm *ORM) Count(clearCache bool) (int64, error)
- func (orm *ORM) DeleteByWhere(where map[string]interface{}) (affected int64, err error)
- func (orm *ORM) Distinct(b bool) *ORM
- func (orm *ORM) GroupBy(cols ...string) *ORM
- func (orm *ORM) Having(col string, value interface{}) *ORM
- func (orm *ORM) HavingSome(where Having) *ORM
- func (orm *ORM) InsertMany(data []interface{}, trans bool) (affected int64, insertIds []int64, err error)
- func (orm *ORM) InsertManySameClos(data []interface{}, cols []string, batchSize int, trans bool) (affected int64, err error)
- func (orm *ORM) InsertOne(data interface{}) (insertID int64, err error)
- func (orm *ORM) KeepQuery(b bool) *ORM
- func (orm *ORM) Limit(size uint) *ORM
- func (orm *ORM) Order(cols ...string) *ORM
- func (orm *ORM) OverLimit(over, size uint) *ORM
- func (orm *ORM) Page(pageNo, pageSize uint) *ORM
- func (orm *ORM) PageData(result interface{}, flat bool, pageNo, pageSize uint) (*Paging, error)
- func (orm *ORM) PrimaryKey(k string) *ORM
- func (orm *ORM) Query(pair ...interface{}) *ORM
- func (orm *ORM) ReplaceMany(data []interface{}, trans bool) (affected int64, insertIds []int64, err error)
- func (orm *ORM) ReplaceManySameClos(data []interface{}, cols []string, batchSize int, trans bool) (affected int64, err error)
- func (orm *ORM) ReplaceOne(data interface{}) (affected int64, err error)
- func (orm *ORM) SaveMany(data []interface{}, trans bool) (affected int64, err error)
- func (orm *ORM) Select(cols ...string) *ORM
- func (orm *ORM) SelectColLinkStr(s string) *ORM
- func (orm *ORM) SelectForUpdate(b bool) *ORM
- func (orm *ORM) ToData(result interface{}, flat bool) error
- func (orm *ORM) ToSQL(flat bool) string
- func (orm *ORM) UpdateByWhere(update map[string]interface{}, where Where) (affected int64, err error)
- func (orm *ORM) UpdateMany(data []interface{}, trans bool) (affected int64, err error)
- func (orm *ORM) UpdateOne(data interface{}) (affected int64, err error)
- func (orm *ORM) UpsertMany(data []interface{}, trans bool) (affected int64, insertIDs []int64, err error)
- func (orm *ORM) UpsertManySameClos(data []interface{}, cols []string, batchSize int, trans bool) (affected int64, err error)
- func (orm *ORM) UpsertOne(data interface{}) (insertID int64, err error)
- func (orm *ORM) Where(col string, value interface{}) *ORM
- func (orm *ORM) Wheres(where Where) *ORM
- type Order
- type Paging
- type Reference
- type Select
- type Tb1
- type Tb2
- type Tb3
- type Tx
- type Verify
- type Where
Constants ¶
This section is empty.
Variables ¶
var ErrClient = fmt.Errorf("db and tx are all nil")
var ErrTargetNotSettable = errors.New("[scanner]: target is not settable! a pointer is required")
Functions ¶
func SetGlobalVerify ¶
func SetGlobalVerify(v Verify)
func SimpleCount ¶
func SimpleCount()
func SimpleDeleteByWhere ¶
func SimpleDeleteByWhere()
func SimpleInsertMany ¶
func SimpleInsertMany()
func SimpleInsertManySameClos ¶
func SimpleInsertManySameClos()
func SimpleInsertOne ¶
func SimpleInsertOne()
func SimpleInsertOne2 ¶
func SimpleInsertOne2()
func SimpleReplaceMany ¶
func SimpleReplaceMany()
func SimpleReplaceManySameClos ¶
func SimpleReplaceManySameClos()
func SimpleReplaceOne ¶
func SimpleReplaceOne()
func SimpleToData ¶
func SimpleToData()
func SimpleToData2 ¶
func SimpleToData2()
func SimpleUpdateByWhere ¶
func SimpleUpdateByWhere()
func SimpleUpdateMany ¶
func SimpleUpdateMany()
func SimpleUpsertManySameClos ¶
func SimpleUpsertManySameClos()
func SimpleUpsertOne ¶
func SimpleUpsertOne()
func Struct2Map ¶
func TestTransSession ¶
func TestTransSession()
Types ¶
type BaseQuery ¶
type BaseQuery struct {
RefConf *Reference
// 字段别名链接字符串,SelectRaw 为false有效
SelectColLinkStr string
// true:使用原始字段名;false:使用别名
SelectRaw bool
TableName string
Distinct bool
SelectForUpdate bool
Select Select
Order Order
Limit Limit
Where Where
GroupBy GroupBy
Having Having
// contains filtered or unexported fields
}
BaseQuery # 为内置符号,标志为原始字段,不进行任何处理,仅在以下数据有效: Select Order GroupBy Where Having
type ORM ¶
type ORM struct {
// 查询配置数据
Q *mysqlQuery
// contains filtered or unexported fields
}
ORM # 为内置符号,标志为原始字段,不进行任何处理,仅在以下数据有效: Select Order GroupBy Where Having
func NewORMWithTx ¶
func (*ORM) ClearCache ¶
func (*ORM) DeleteByWhere ¶
func (*ORM) HavingSome ¶
func (*ORM) InsertMany ¶
func (*ORM) InsertManySameClos ¶
func (orm *ORM) InsertManySameClos(data []interface{}, cols []string, batchSize int, trans bool) (affected int64, err error)
InsertManySameClos data 需要处理的数据集合,数据格式为:map、*struct、struct,字段不在 cols 的被赋值null cols 需要处理的字段集合 batchSize 单次并发数量 trans 是否使用事务
func (*ORM) PrimaryKey ¶
func (*ORM) ReplaceMany ¶
func (*ORM) ReplaceManySameClos ¶
func (orm *ORM) ReplaceManySameClos(data []interface{}, cols []string, batchSize int, trans bool) (affected int64, err error)
ReplaceManySameClos data 需要处理的数据集合,数据格式为:map、*struct、struct,字段不在 cols 的被赋值null cols 需要处理的字段集合 batchSize 单次并发数量 trans 是否使用事务
func (*ORM) ReplaceOne ¶
func (*ORM) SaveMany ¶
SaveMany data 需要处理的数据集合,数据格式为:map、*struct、struct,字段不在 cols 的被赋值null cols 需要处理的字段集合 batchSize 单次并发数量 trans 是否使用事务
func (*ORM) Select ¶
Select 参数:* 主表所有字段;tag.* tag对应表所有字段;tag1.tag2.* tag1表的tag2的所有字段;以此类推 *0 等价 * 只考虑主表,不展开子表 *1 对应层级的表展开一层(主表+一级关联表,二级以下联表不算) *2 对应层级的表展开二层(主表+一级关联表+二级关联表,三级以下联表不算) *n 对应层级的表展开n层(主表+1级关联表+2级关联表+...+n级关联表,n+1级以下联表不算) 上述法则同样适用于tag.*1,此时的主表为tag,以此类推 tag1.tag2.*1,主表为tag1.tag2 字段排除:优先级最高 -name:删除name字段;-* 移除主表字段; -tag.name:删除tag表对应的name字段;-tag.*:删除整个tag表所有字段 排除字段也支持 *n 语法,-*n *n与- 均不可与 # 混用
func (*ORM) SelectColLinkStr ¶
func (*ORM) SelectForUpdate ¶
func (*ORM) UpdateByWhere ¶
func (*ORM) UpdateMany ¶
UpdateMany 主键,id 不能为空,为空将更新失败
func (*ORM) UpsertMany ¶
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
func NewReference ¶
func NewReference() *Reference
func (*Reference) AddTableDef ¶
AddTableDef 添加表定义