wrapper

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: Zlib Imports: 6 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 *Condition) error

func (*Base) First

func (b *Base) First(model interface{}, cond *Condition) 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) Select

func (b *Base) Select(model interface{}, cond *Condition) error

func (*Base) UpdateColumn

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

func (*Base) Updates

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

func (*Base) WithOrder

func (b *Base) WithOrder(order string) *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) 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) 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) 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) 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) 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 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) SelectPage

func (page *Page) SelectPage(model interface{}, cond *Condition) error

SelectPage 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

Jump to

Keyboard shortcuts

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