psl

package module
v0.0.0-...-51def33 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2019 License: MIT Imports: 4 Imported by: 0

README

PSL

持久化标准层 Persistent Standard Layer

Documentation

Index

Constants

View Source
const (
	SortAsc  = "ASC"
	SortDesc = "DESC"
)
View Source
const (
	OrRelation  = "OR"
	AndRelation = "AND"
)
View Source
const (
	EqualFilter
	NotEqualFilter
	GreaterThanFilter
	GreaterThanOrEqualFilter
	LessThanFilter
	LessThanOrEqualFilter
	ContainFilter
	NotContainFilter
	BitContainFilter
	BitNotContainFilter
	StartWithFilter
	NotStartWithFilter
	EndWithFilter
	NotEndWithFilter
	IsNullFilter
	NotNullFilter
	InGroupFilter
	NotInGroupFilter
	BetweenFilter
	NotBetweenFilter
	InSubQueryFilter
	NotInSubQueryFilter
)

Variables

This section is empty.

Functions

func Use

func Use(driver Driver)

Types

type Bundle

type Bundle struct {
	Inserts []*Insert
	Deletes []*Delete
	Updates []*Update
	// contains filtered or unexported fields
}

func NewBundle

func NewBundle() *Bundle

func (*Bundle) AddDelete

func (b *Bundle) AddDelete(exps ...*Delete) *Bundle

func (*Bundle) AddInsert

func (b *Bundle) AddInsert(exps ...*Insert) *Bundle

func (*Bundle) AddUpdate

func (b *Bundle) AddUpdate(exps ...*Update) *Bundle

func (*Bundle) Execute

func (b *Bundle) Execute() error

func (*Bundle) IsMulti

func (b *Bundle) IsMulti() bool

func (*Bundle) Len

func (b *Bundle) Len() int

func (*Bundle) Use

func (b *Bundle) Use(driver Driver) *Bundle

type Columns

type Columns []string

Columns 列名

func (Columns) IsValid

func (cs Columns) IsValid() bool

type Condition

type Condition struct {
	Filters  Filters
	Children SubCond
	Relation string
}

Condition 条件

func AND

func AND(args ...interface{}) Condition

func OR

func OR(args ...interface{}) Condition

func (Condition) IsValid

func (c Condition) IsValid() bool

type DefaultParser

type DefaultParser struct{}

func (DefaultParser) NameFunc

func (d DefaultParser) NameFunc(s string) string

func (DefaultParser) TagFunc

func (d DefaultParser) TagFunc(s string) string

func (DefaultParser) TagName

func (d DefaultParser) TagName() string

type Delete

type Delete struct {
	From string
	// contains filtered or unexported fields
}

Delete 删除表达式

func NewDelete

func NewDelete(from string) *Delete

func (*Delete) Execute

func (d *Delete) Execute() error

func (*Delete) SetAND

func (d *Delete) SetAND(args ...interface{}) *Delete

func (*Delete) SetCond

func (d *Delete) SetCond(arg Condition) *Delete

func (*Delete) SetForce

func (d *Delete) SetForce() *Delete

func (*Delete) SetOR

func (d *Delete) SetOR(args ...interface{}) *Delete

func (*Delete) Use

func (d *Delete) Use(driver Driver) *Delete

type Driver

type Driver interface {
	GetOne(dest interface{}, exp *Select) error
	GetAll(dest interface{}, exp *Select) error
	GetPage(dest interface{}, exp *Select) (int, error)
	ExecInsert(exp *Insert) error
	ExecUpdate(exp *Update) error
	ExecDelete(exp *Delete) error
	ExecBundle(exp *Bundle) error
	SetMapParser(psr Parser)
}

type Filter

type Filter struct {
	Type   int
	Column string
	Value  interface{}
}

Filter 过滤条件

func Between

func Between(column string, first interface{}, second interface{}) Filter

func BitContain

func BitContain(column string, value interface{}) Filter

func BitNotContain

func BitNotContain(column string, value interface{}) Filter

func Contain

func Contain(column string, value interface{}) Filter

func EndWith

func EndWith(column string, value interface{}) Filter

func Equal

func Equal(column string, value interface{}) Filter

func GreaterThan

func GreaterThan(column string, value interface{}) Filter

func GreaterThanOrEqual

func GreaterThanOrEqual(column string, value interface{}) Filter

func InGroup

func InGroup(column string, value interface{}) Filter

func InSubQuery

func InSubQuery(column string, value Select) Filter

func IsNull

func IsNull(column string) Filter

func LessThan

func LessThan(column string, value interface{}) Filter

func LessThanOrEqual

func LessThanOrEqual(column string, value interface{}) Filter

func NotBetween

func NotBetween(column string, first interface{}, second interface{}) Filter

func NotContain

func NotContain(column string, value interface{}) Filter

func NotEndWith

func NotEndWith(column string, value interface{}) Filter

func NotEqual

func NotEqual(column string, value interface{}) Filter

func NotInGroup

func NotInGroup(column string, value interface{}) Filter

func NotInSubQuery

func NotInSubQuery(column string, value Select) Filter

func NotNull

func NotNull(column string) Filter

func NotStartWith

func NotStartWith(column string, value interface{}) Filter

func StartWith

func StartWith(column string, value interface{}) Filter

type Filters

type Filters []Filter

Filters 过滤集合

type GroupBy

type GroupBy struct{ Columns }

GroupBy 分组

type Insert

type Insert struct {
	Into string
	// contains filtered or unexported fields
}

Insert 新增表达式

func NewInsert

func NewInsert(into string) *Insert

func (*Insert) Execute

func (i *Insert) Execute() error

func (*Insert) IsBatch

func (i *Insert) IsBatch() bool

func (*Insert) SetCols

func (i *Insert) SetCols(args ...string) *Insert

func (*Insert) SetVals

func (i *Insert) SetVals(arg interface{}) *Insert

func (*Insert) Use

func (i *Insert) Use(driver Driver) *Insert

func (*Insert) ValuesRef

func (v *Insert) ValuesRef() reflect.Value

type OrderBy

type OrderBy struct {
	Columns   []string
	Direction string
}

OrderBy 排序

func (OrderBy) IsValid

func (ob OrderBy) IsValid() bool

type Paging

type Paging struct {
	Offset   int
	PageNo   int
	PageSize int
}

Paging 分页

func (Paging) GetOffset

func (p Paging) GetOffset() int

func (Paging) IsValid

func (p Paging) IsValid() bool

type Parser

type Parser interface {
	TagName() string
	TagFunc(string) string
	NameFunc(string) string
}

type Select

type Select struct {
	From    string
	Columns Columns
	Paging  Paging
	OrderBy []OrderBy
	GroupBy GroupBy
	// contains filtered or unexported fields
}

Select 查询表达式

func NewSelect

func NewSelect(from string) *Select

func (*Select) GetAll

func (s *Select) GetAll(dest interface{}) error

func (*Select) GetOne

func (s *Select) GetOne(dest interface{}) error

func (*Select) GetPage

func (s *Select) GetPage(dest interface{}) (int, error)

func (*Select) SetAND

func (s *Select) SetAND(args ...interface{}) *Select

func (*Select) SetASC

func (s *Select) SetASC(args ...string) *Select

func (*Select) SetCols

func (s *Select) SetCols(args ...string) *Select

func (*Select) SetCond

func (s *Select) SetCond(arg Condition) *Select

func (*Select) SetDESC

func (s *Select) SetDESC(args ...string) *Select

func (*Select) SetForce

func (s *Select) SetForce() *Select

func (*Select) SetGroup

func (s *Select) SetGroup(args ...string) *Select

func (*Select) SetOR

func (s *Select) SetOR(args ...interface{}) *Select

func (*Select) SetPage

func (s *Select) SetPage(offset, number, size int) *Select

func (*Select) Use

func (s *Select) Use(driver Driver) *Select

type SubCond

type SubCond []Condition

SubCond 子条件

func (SubCond) IsValid

func (sc SubCond) IsValid() bool

type Update

type Update struct {
	Table string
	// contains filtered or unexported fields
}

Update 更新表达式

func NewUpdate

func NewUpdate(table string) *Update

func (*Update) Execute

func (u *Update) Execute() error

func (*Update) SetAND

func (u *Update) SetAND(args ...interface{}) *Update

func (*Update) SetCols

func (u *Update) SetCols(args ...string) *Update

func (*Update) SetCond

func (u *Update) SetCond(arg Condition) *Update

func (*Update) SetForce

func (u *Update) SetForce() *Update

func (*Update) SetOR

func (u *Update) SetOR(args ...interface{}) *Update

func (*Update) SetVals

func (u *Update) SetVals(arg interface{}) *Update

func (*Update) Use

func (u *Update) Use(driver Driver) *Update

func (*Update) ValuesRef

func (v *Update) ValuesRef() reflect.Value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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