Documentation
¶
Index ¶
- Constants
- func LoopPager(fast *FastObject, size int, call func(index int))
- type CacheConfig
- type Cnd
- func (self *Cnd) AddOther(part string) *Cnd
- func (self *Cnd) Agg(logic int, key string, alias ...string) *Cnd
- func (self *Cnd) Asc(keys ...string) *Cnd
- func (self *Cnd) Between(key string, value1 interface{}, value2 interface{}) *Cnd
- func (self *Cnd) Cache(config CacheConfig) *Cnd
- func (self *Cnd) Collation(collation *Collation) *Cnd
- func (self *Cnd) Desc(keys ...string) *Cnd
- func (self *Cnd) Distinct(keys ...string) *Cnd
- func (self *Cnd) Eq(key string, value interface{}) *Cnd
- func (self *Cnd) FastPage(fast *FastObject) *Cnd
- func (self *Cnd) Fields(keys ...string) *Cnd
- func (self *Cnd) From(fromTable string) *Cnd
- func (self *Cnd) GetPageResult() dialect.PageResult
- func (self *Cnd) Groupby(keys ...string) *Cnd
- func (self *Cnd) Gt(key string, value interface{}) *Cnd
- func (self *Cnd) Gte(key string, value interface{}) *Cnd
- func (self *Cnd) In(key string, values ...interface{}) *Cnd
- func (self *Cnd) InDate(key string, value1 interface{}, value2 interface{}) *Cnd
- func (self *Cnd) IsNotNull(key string) *Cnd
- func (self *Cnd) IsNull(key string) *Cnd
- func (self *Cnd) Join(join int, table string, on string) *Cnd
- func (self *Cnd) Like(key string, value interface{}) *Cnd
- func (self *Cnd) Limit(pageNo int64, pageSize int64) *Cnd
- func (self *Cnd) Lt(key string, value interface{}) *Cnd
- func (self *Cnd) Lte(key string, value interface{}) *Cnd
- func (self *Cnd) NotBetween(key string, value1 interface{}, value2 interface{}) *Cnd
- func (self *Cnd) NotEq(key string, value interface{}) *Cnd
- func (self *Cnd) NotFields(keys ...string) *Cnd
- func (self *Cnd) NotIn(key string, values ...interface{}) *Cnd
- func (self *Cnd) NotLike(key string, value interface{}) *Cnd
- func (self *Cnd) Offset(offset int64, limit int64) *Cnd
- func (self *Cnd) Or(cnds ...interface{}) *Cnd
- func (self *Cnd) Orderby(key string, sortby int) *Cnd
- func (self *Cnd) ResultSize(size int64) *Cnd
- func (self *Cnd) Sample(size int64) *Cnd
- func (self *Cnd) UnEscape() *Cnd
- func (self *Cnd) Upset(keys []string, values ...interface{}) *Cnd
- func (self *Cnd) UseEscape() *Cnd
- type Collation
- type Condition
- type FastObject
- type FromCond
- type Index
- type JoinCond
- type KV
- type Limit
- type Object
Constants ¶
View Source
const ( EQ_ = iota NOT_EQ_ LT_ LTE_ GT_ GTE_ IS_NULL_ IS_NOT_NULL_ BETWEEN_ BETWEEN2_ NOT_BETWEEN_ IN_ NOT_IN_ LIKE_ NOT_LIKE_ OR_ ORDER_BY_ LEFT_ RIGHT_ INNER_ SUM_ AVG_ MIN_ MAX_ CNT_ )
数据库操作类型枚举
View Source
const ( ID = "ID" Key = "key" Auto = "auto" Ignore = "ignore" Bson = "bson" Json = "json" Mg = "mg" True = "true" Date = "date" Date2 = "date2" Blob = "blob" Safe = "safe" DB = "db" Comment = "comment" Charset = "charset" Collate = "collate" )
View Source
const ASC_ = 1
View Source
const DESC_ = 2
Variables ¶
This section is empty.
Functions ¶
func LoopPager ¶ added in v1.1.0
func LoopPager(fast *FastObject, size int, call func(index int))
Types ¶
type CacheConfig ¶
type CacheConfig struct {
// 16字节字段组 (2个字段,32字节)
Prefix string // 16字节 (8+8) - string字段
Key string // 16字节 (8+8) - string字段
// 8字节字段组 (1个字段,8字节)
Expire int // 8字节 - int字段
// bool字段组 (1个字段,1字节,会产生7字节填充到8字节对齐)
Open bool // 1字节 - bool字段
}
CacheConfig 结构体 - 40字节 (4个字段,8字节对齐,无填充) 排列优化:string字段在前,int字段居中,bool字段在后
type Cnd ¶
type Cnd struct {
// 24字节切片字段组 (9个字段,216字节)
ConditPart []string // 24字节 - 切片字段
Conditions []Condition // 24字节 - 切片字段
AnyFields []string // 24字节 - 切片字段
AnyNotFields []string // 24字节 - 切片字段
Distincts []string // 24字节 - 切片字段
Groupbys []string // 24字节 - 切片字段
Orderbys []Condition // 24字节 - 切片字段
Aggregates []Condition // 24字节 - 切片字段
JoinCond []*JoinCond // 24字节 - 切片字段
// 16字节字段组 (3个字段,48字节)
Model Object // 16字节 - interface字段
Pagination dialect.Dialect // 16字节 - 结构体字段 (假设)
CacheConfig CacheConfig // 16字节 - 结构体字段 (假设)
// 8字节字段组 (5个字段,40字节)
CollationConfig *Collation // 8字节 - 指针字段
FromCond *FromCond // 8字节 - 指针字段
Upsets map[string]interface{} // 8字节 - map字段
SampleSize int64 // 8字节 - int64字段
LimitSize int64 // 固定截取结果集数量 - 8字节
// bool字段组 (1个字段,1字节,会产生7字节填充)
Escape bool // 1字节 - bool字段
}
Cnd 结构体 - 376字节 (20个字段,8字节对齐,0字节填充) 排列优化:按字段大小从大到小排列,24字节切片在前,16字节结构体居中,8字节字段在后
func (*Cnd) FastPage ¶ added in v1.0.49
func (self *Cnd) FastPage(fast *FastObject) *Cnd
func (*Cnd) GetPageResult ¶ added in v1.0.54
func (self *Cnd) GetPageResult() dialect.PageResult
func (*Cnd) NotBetween ¶
not between
type Collation ¶ added in v1.0.71
type Collation struct {
// 16字节字段组 (4个字段,64字节)
Locale string `bson:",omitempty"` // The locale - 16字节 (8+8)
CaseFirst string `bson:",omitempty"` // The case ordering - 16字节 (8+8)
Alternate string `bson:",omitempty"` // Whether spaces and punctuation are considered base characters - 16字节 (8+8)
MaxVariable string `bson:",omitempty"` // Which characters are affected by alternate: "shifted" - 16字节 (8+8)
// 8字节字段组 (1个字段,8字节)
Strength int `bson:",omitempty"` // The number of comparison levels to use - 8字节
// bool字段组 (3个字段,3字节,会产生5字节填充到8字节对齐)
CaseLevel bool `bson:",omitempty"` // The case level - 1字节
NumericOrdering bool `bson:",omitempty"` // Whether to order numbers based on numerical order and not collation order - 1字节
Normalization bool `bson:",omitempty"` // Causes text to be normalized into Unicode NFD - 1字节
Backwards bool `bson:",omitempty"` // Causes secondary differences to be considered in reverse order, as it is done in the French language - 1字节
}
Collation 结构体 - 80字节 (8个字段,8字节对齐,无填充) 排列优化:string字段在前,int字段居中,bool字段在后连续排列
type Condition ¶
type Condition struct {
// 16字节字段组 (2个字段,32字节)
Key string // 16字节 (8+8) - string字段
Alias string // 16字节 (8+8) - string字段
// 16字节字段组 (2个字段,32字节)
Value interface{} // 16字节 (8+8) - interface字段
Values []interface{} // 24字节 (8+8+8) - slice字段
// 8字节字段组 (1个字段,8字节)
Logic int // 8字节 - int字段
}
Condition 结构体 - 80字节 (5个字段,8字节对齐,无填充) 排列优化:按字段大小分组,string字段在前,interface字段居中,int字段在后
type FastObject ¶ added in v1.1.0
type FastObject struct {
PrevID int64
LastID int64
Size int64
CountQ bool
IsPrev bool
IsNext bool
// contains filtered or unexported fields
}
func GetFast ¶ added in v1.1.0
func GetFast(req common.BaseReq) *FastObject
func (*FastObject) Asc ¶ added in v1.1.0
func (s *FastObject) Asc() *FastObject
func (*FastObject) Desc ¶ added in v1.1.0
func (s *FastObject) Desc() *FastObject
func (*FastObject) Key ¶ added in v1.1.0
func (s *FastObject) Key(k string) *FastObject
func (*FastObject) Sort ¶ added in v1.1.0
func (s *FastObject) Sort(v int) *FastObject
type FromCond ¶
type FromCond struct {
Table string // 16字节 (8+8) - string字段
Alias string // 16字节 (8+8) - string字段
}
FromCond 结构体 - 32字节 (2个字段,8字节对齐,无填充) 排列优化:string字段连续排列
type JoinCond ¶
type JoinCond struct {
// 16字节字段组 (3个字段,48字节)
Table string // 16字节 (8+8) - string字段
Alias string // 16字节 (8+8) - string字段
On string // 16字节 (8+8) - string字段
// 8字节字段组 (1个字段,8字节)
Type int // 8字节 - int字段
}
JoinCond 结构体 - 56字节 (4个字段,8字节对齐,无填充) 排列优化:string字段在前,int字段在后
type Limit ¶ added in v1.1.0
type Limit struct {
// 分页条数
Limit int64 `json:"limit"`
// 总数据条数,查询条件prevID=0和lastID=0的时候触发查询count数量,一般在首页查询触发
Total int64 `json:"total"`
// 上一页的划分ID
LastID int64 `json:"lastID"`
// 下一页的划分ID
PrevID int64 `json:"prevID"`
}
func LimitPager ¶ added in v1.1.0
func (Limit) MarshalEasyJSON ¶ added in v1.1.0
MarshalEasyJSON supports easyjson.Marshaler interface
func (Limit) MarshalJSON ¶ added in v1.1.0
MarshalJSON supports json.Marshaler interface
func (*Limit) UnmarshalEasyJSON ¶ added in v1.1.0
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Limit) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON supports json.Unmarshaler interface
Click to show internal directories.
Click to hide internal directories.