wrapper

package
v1.1.23 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Zlib Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Eq   = "="
	NEq  = "<>"
	Lt   = "<"
	LtEq = "<="
	Gt   = ">"
	GtEq = ">="

	In      = "IN"
	Like    = "LIKE"
	Between = "BETWEEN"
	And     = "AND"
	Or      = "OR"
)

Operate

Variables

This section is empty.

Functions

func IsNotFound

func IsNotFound(db *gorm.DB) int

func IsValid

func IsValid(r interface{}) bool

Types

type Base

type Base struct {
	DB *gorm.DB

	Results interface{}
	// contains filtered or unexported fields
}

func (*Base) Cancel

func (b *Base) Cancel()

func (*Base) Count

func (b *Base) Count(model interface{}, count *int64) error

func (*Base) Create

func (b *Base) Create(model interface{}, opts ...Option) error

func (*Base) Delete

func (b *Base) Delete(model interface{}, cond IQuery) error

func (*Base) Find added in v0.5.1

func (b *Base) Find(model interface{}, where IQuery, sel ISelect) error

func (*Base) First

func (b *Base) First(model interface{}, where IQuery, sel ISelect) error

func (*Base) Get

func (b *Base) Get(model interface{}) (result interface{}, err error)

Get 获取

func (*Base) Gets

func (b *Base) Gets(model interface{}) (results []*interface{}, err error)

Gets 获取批量结果

func (*Base) NewDB

func (b *Base) NewDB() *gorm.DB

func (*Base) UpdateColumn

func (b *Base) UpdateColumn(model interface{}, where IQuery, column string, value interface{}) error

func (*Base) Updates

func (b *Base) Updates(model interface{}, where IQuery, opts ...Option) error

func (*Base) WithOrder

func (b *Base) WithOrder(order interface{}) *Base

func (*Base) WithResult

func (b *Base) WithResult(result interface{}) *Base

type Condition

type Condition struct {
	// contains filtered or unexported fields
}

func (*Condition) And

func (sq *Condition) And(column, operator string, value interface{}) *Condition

And

 @param column
*  @param operator "=、<小于、>大于、>=大于等于、<=小于等于、<>以及不等于"

func (*Condition) AndEq added in v0.5.1

func (sq *Condition) AndEq(column string, value interface{}) *Condition

func (*Condition) AndGt added in v0.5.1

func (sq *Condition) AndGt(column string, value interface{}) *Condition

func (*Condition) AndGtEq added in v0.5.1

func (sq *Condition) AndGtEq(column string, value interface{}) *Condition

func (*Condition) AndLt added in v0.5.1

func (sq *Condition) AndLt(column string, value interface{}) *Condition

func (*Condition) AndLtEq added in v0.5.1

func (sq *Condition) AndLtEq(column string, value interface{}) *Condition

func (*Condition) AndNEq added in v0.5.1

func (sq *Condition) AndNEq(column string, value interface{}) *Condition

func (*Condition) Column

func (sq *Condition) Column(column string) *Condition

Column

  • example db.Where("created_at BETWEEN ? AND ?", lastWeek, today).Find(&users)

func (*Condition) Compose

func (sq *Condition) Compose(column string, operator string, value interface{}) *Condition

func (*Condition) ComposeFrom added in v0.5.39

func (sq *Condition) ComposeFrom(src *Condition, operator string) *Condition

ComposeFrom 组合

func (*Condition) Cond

func (sq *Condition) Cond() string

func (*Condition) Eq

func (sq *Condition) Eq(column string, value interface{}) *Condition

func (*Condition) Gt

func (sq *Condition) Gt(column string, value interface{}) *Condition

func (*Condition) GtEq

func (sq *Condition) GtEq(column string, value interface{}) *Condition

func (*Condition) In

func (sq *Condition) In(column string, value interface{}) *Condition

func (*Condition) Is

func (sq *Condition) Is() bool

func (*Condition) IsFirst added in v0.5.40

func (sq *Condition) IsFirst() bool

func (*Condition) Like

func (sq *Condition) Like(column string, value interface{}) *Condition

Like

@example db.Where("name LIKE ?", "%jin%").Find(&users)
* Condition.Like("name","%jin%")

func (*Condition) Lt

func (sq *Condition) Lt(column string, value interface{}) *Condition

func (*Condition) LtEq

func (sq *Condition) LtEq(column string, value interface{}) *Condition

func (*Condition) Modifier

func (sq *Condition) Modifier(m string) *Condition

Modifier 修饰符,比如 ()

func (*Condition) ModifierF added in v0.5.39

func (sq *Condition) ModifierF(f string, m ...interface{}) *Condition

func (*Condition) NEq

func (sq *Condition) NEq(column string, value interface{}) *Condition

func (*Condition) Operate

func (sq *Condition) Operate(operator string) *Condition

Operate

@param operator
* @example created_at BETWEEN ? AND ?
* Condition.Column("created_at").Operate("BETWEEN").Operate("AND").Values(11333,34444)

func (*Condition) Or

func (sq *Condition) Or(column, operator string, value interface{}) *Condition

func (*Condition) OrEq added in v0.5.1

func (sq *Condition) OrEq(column string, value interface{}) *Condition

func (*Condition) OrGt added in v0.5.1

func (sq *Condition) OrGt(column string, value interface{}) *Condition

func (*Condition) OrGtEq added in v0.5.1

func (sq *Condition) OrGtEq(column string, value interface{}) *Condition

func (*Condition) OrLt added in v0.5.1

func (sq *Condition) OrLt(column string, value interface{}) *Condition

func (*Condition) OrLtEq added in v0.5.1

func (sq *Condition) OrLtEq(column string, value interface{}) *Condition

func (*Condition) OrNEq added in v0.5.1

func (sq *Condition) OrNEq(column string, value interface{}) *Condition

func (*Condition) Query added in v0.5.1

func (sq *Condition) Query() string

func (*Condition) Reset

func (sq *Condition) Reset() *Condition

func (*Condition) Value

func (sq *Condition) Value() []interface{}

func (*Condition) Values

func (sq *Condition) Values(value ...interface{}) *Condition

type IQuery added in v0.5.4

type IQuery interface {
	Is() bool
	Query() string
	Value() []interface{}
}

type ISelect added in v0.5.4

type ISelect interface {
	Is() bool
	Query() []string
	Value() []interface{}
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option overrides behavior of Connect.

func With

func With(name string, value interface{}) Option

func WithId

func WithId(value interface{}) Option

type OptionFunc

type OptionFunc func(*Options)

type Options

type Options struct {
	Query map[string]interface{}
}

type Page

type Page struct {
	Base
	Total int64
	// contains filtered or unexported fields
}

func NewPage

func NewPage(db *gorm.DB, timeout time.Duration) *Page

func (*Page) FindPage added in v0.5.1

func (page *Page) FindPage(model interface{}, where IQuery, sel ISelect) error

FindPage param results := make([]object, 0)

func (*Page) WithOffset

func (page *Page) WithOffset(offset int) *Page

func (*Page) WithSize

func (page *Page) WithSize(size int) *Page

type Select added in v0.5.4

type Select struct {
	// contains filtered or unexported fields
}

func (*Select) Add added in v0.5.4

func (sel *Select) Add(column string) *Select

func (*Select) Is added in v0.5.4

func (sel *Select) Is() bool

func (*Select) Query added in v0.5.4

func (sel *Select) Query() []string

func (*Select) Value added in v0.5.4

func (sel *Select) Value() []interface{}

Jump to

Keyboard shortcuts

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