sqlc

package
v1.0.156 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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"
	Blob    = "blob"
	DB      = "db"
	Comment = "comment"
	Charset = "charset"
	Collate = "collate"
)
View Source
const ASC_ = 1
View Source
const DESC_ = 2

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheConfig

type CacheConfig struct {
	Open   bool
	Prefix string
	Key    string
	Expire int
}

缓存结果集参数

type Cnd

type Cnd struct {
	ConditPart      []string
	Conditions      []Condition
	AnyFields       []string
	AnyNotFields    []string
	Distincts       []string
	Groupbys        []string
	Orderbys        []Condition
	Aggregates      []Condition
	Upsets          map[string]interface{}
	Model           Object
	CollationConfig *Collation
	Pagination      dialect.Dialect
	FromCond        *FromCond
	JoinCond        []*JoinCond
	SampleSize      int64
	LimitSize       int64 // 固定截取结果集数量
	CacheConfig     CacheConfig
	Escape          bool
}

数据库操作汇总逻辑条件对象

func M

func M(model ...Object) *Cnd

args[0]=对象类型

func (*Cnd) AddOther

func (self *Cnd) AddOther(part string) *Cnd

add other

func (*Cnd) Agg

func (self *Cnd) Agg(logic int, key string, alias ...string) *Cnd

聚合函数

func (*Cnd) Asc

func (self *Cnd) Asc(keys ...string) *Cnd

按字段排序升序

func (*Cnd) Between

func (self *Cnd) Between(key string, value1 interface{}, value2 interface{}) *Cnd

between, >= a b =<

func (*Cnd) Cache

func (self *Cnd) Cache(config CacheConfig) *Cnd

缓存指定结果集

func (*Cnd) Collation added in v1.0.71

func (self *Cnd) Collation(collation *Collation) *Cnd

func (*Cnd) Desc

func (self *Cnd) Desc(keys ...string) *Cnd

按字段排序倒序

func (*Cnd) Distinct

func (self *Cnd) Distinct(keys ...string) *Cnd

筛选字段去重

func (*Cnd) Eq

func (self *Cnd) Eq(key string, value interface{}) *Cnd

=

func (*Cnd) FastPage added in v1.0.49

func (self *Cnd) FastPage(key string, sort int, prevID, lastID, pageSize int64, countQ ...bool) *Cnd

func (*Cnd) Fields

func (self *Cnd) Fields(keys ...string) *Cnd

筛选指定字段查询

func (*Cnd) From

func (self *Cnd) From(fromTable string) *Cnd

复杂查询设定首个from table as

func (*Cnd) GetPageResult added in v1.0.54

func (self *Cnd) GetPageResult() dialect.PageResult

func (*Cnd) Groupby

func (self *Cnd) Groupby(keys ...string) *Cnd

按字段分组

func (*Cnd) Gt

func (self *Cnd) Gt(key string, value interface{}) *Cnd

>

func (*Cnd) Gte

func (self *Cnd) Gte(key string, value interface{}) *Cnd

>=

func (*Cnd) In

func (self *Cnd) In(key string, values ...interface{}) *Cnd

in

func (*Cnd) InDate

func (self *Cnd) InDate(key string, value1 interface{}, value2 interface{}) *Cnd

时间范围专用, >= a b <

func (*Cnd) IsNotNull

func (self *Cnd) IsNotNull(key string) *Cnd

is not null

func (*Cnd) IsNull

func (self *Cnd) IsNull(key string) *Cnd

is null

func (*Cnd) Join

func (self *Cnd) Join(join int, table string, on string) *Cnd

left join

func (*Cnd) Like

func (self *Cnd) Like(key string, value interface{}) *Cnd

like

func (*Cnd) Limit

func (self *Cnd) Limit(pageNo int64, pageSize int64) *Cnd

limit,以页数跨度查询

func (*Cnd) Lt

func (self *Cnd) Lt(key string, value interface{}) *Cnd

<

func (*Cnd) Lte

func (self *Cnd) Lte(key string, value interface{}) *Cnd

<=

func (*Cnd) NotBetween

func (self *Cnd) NotBetween(key string, value1 interface{}, value2 interface{}) *Cnd

not between

func (*Cnd) NotEq

func (self *Cnd) NotEq(key string, value interface{}) *Cnd

<>

func (*Cnd) NotFields

func (self *Cnd) NotFields(keys ...string) *Cnd

筛选过滤指定字段查询

func (*Cnd) NotIn

func (self *Cnd) NotIn(key string, values ...interface{}) *Cnd

not in

func (*Cnd) NotLike

func (self *Cnd) NotLike(key string, value interface{}) *Cnd

not like

func (*Cnd) Offset

func (self *Cnd) Offset(offset int64, limit int64) *Cnd

offset,以下标跨度查询

func (*Cnd) Or

func (self *Cnd) Or(cnds ...interface{}) *Cnd

or

func (*Cnd) Orderby

func (self *Cnd) Orderby(key string, sortby int) *Cnd

按字段排序

func (*Cnd) ResultSize

func (self *Cnd) ResultSize(size int64) *Cnd

固定截取结果集数量

func (*Cnd) Sample

func (self *Cnd) Sample(size int64) *Cnd

随机选取数据条数

func (*Cnd) UnEscape added in v1.0.118

func (self *Cnd) UnEscape() *Cnd

func (*Cnd) Upset

func (self *Cnd) Upset(keys []string, values ...interface{}) *Cnd

指定更新字段

type Collation added in v1.0.71

type Collation struct {
	Locale          string `bson:",omitempty"` // The locale
	CaseLevel       bool   `bson:",omitempty"` // The case level
	CaseFirst       string `bson:",omitempty"` // The case ordering
	Strength        int    `bson:",omitempty"` // The number of comparison levels to use
	NumericOrdering bool   `bson:",omitempty"` // Whether to order numbers based on numerical order and not collation order
	Alternate       string `bson:",omitempty"` // Whether spaces and punctuation are considered base characters
	MaxVariable     string `bson:",omitempty"` // Which characters are affected by alternate: "shifted"
	Normalization   bool   `bson:",omitempty"` // Causes text to be normalized into Unicode NFD
	Backwards       bool   `bson:",omitempty"` // Causes secondary differences to be considered in reverse order, as it is done in the French language
}

type Condition

type Condition struct {
	Logic  int
	Key    string
	Value  interface{}
	Values []interface{}
	Alias  string
}

数据库操作逻辑条件对象

type DefaultObject added in v1.0.5

type DefaultObject struct{}

func (*DefaultObject) GetTable added in v1.0.5

func (o *DefaultObject) GetTable() string

func (*DefaultObject) NewIndex added in v1.0.33

func (o *DefaultObject) NewIndex() []Index

func (*DefaultObject) NewObject added in v1.0.5

func (o *DefaultObject) NewObject() Object

type FromCond

type FromCond struct {
	Table string
	Alias string
}

主表条件对象

type Index added in v1.0.33

type Index struct {
	Name   string
	Key    []string
	Unique bool
}

type JoinCond

type JoinCond struct {
	Type  int
	Table string
	Alias string
	On    string
}

连接表条件对象

type Object added in v1.0.5

type Object interface {
	GetTable() string
	NewObject() Object
	NewIndex() []Index
}

Jump to

Keyboard shortcuts

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