sqlc

package
v1.0.43 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 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"
	Ignore = "ignore"
	Bson   = "bson"
	Json   = "json"
	Mg     = "mg"
	True   = "true"
	Date   = "date"
	Dtype  = "dtype"
)
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
	Pagination   dialect.Dialect
	FromCond     *FromCond
	JoinCond     []*JoinCond
	SampleSize   int64
	LimitSize    int64 // 固定截取结果集数量
	CacheConfig  CacheConfig
}

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

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) 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) Fields

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

筛选指定字段查询

func (*Cnd) From

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

复杂查询设定首个from table as

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) Upset

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

指定更新字段

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