sqlcnd

package
v0.0.0-...-1fffc49 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CursorResult

type CursorResult struct {
	Results interface{} `json:"results"` // 数据
	Cursor  string      `json:"cursor"`  // 下一页
}

Cursor分页返回数据

type OrderByCol

type OrderByCol struct {
	Column string // 排序字段
	Asc    bool   // 是否正序
}

排序信息

type PageResult

type PageResult struct {
	Page    *Paging     `json:"page"`    // 分页信息
	Results interface{} `json:"results"` // 数据
}

分页返回数据

type Paging

type Paging struct {
	Page  int `json:"page"`  // 页码
	Limit int `json:"limit"` // 每页条数
	Total int `json:"total"` // 总数据条数
}

分页请求数据

func GetPaging

func GetPaging(page, limit int) *Paging

func (*Paging) Offset

func (p *Paging) Offset() int

func (*Paging) TotalPage

func (p *Paging) TotalPage() int

type ParamPair

type ParamPair struct {
	Query string        // 查询
	Args  []interface{} // 参数
}

type SqlCnd

type SqlCnd struct {
	SelectCols []string     // 要查询的字段,如果为空,表示查询所有字段
	Params     []ParamPair  // 参数
	Orders     []OrderByCol // 排序
	Paging     *Paging      // 分页
}

func NewSqlCnd

func NewSqlCnd(selectCols ...string) *SqlCnd

selectCols: 需要查询的列

func (*SqlCnd) Asc

func (s *SqlCnd) Asc(column string) *SqlCnd

func (*SqlCnd) Build

func (s *SqlCnd) Build(db *gorm.DB) *gorm.DB

func (*SqlCnd) Count

func (s *SqlCnd) Count(db *gorm.DB, model interface{}) int

func (*SqlCnd) Desc

func (s *SqlCnd) Desc(column string) *SqlCnd

func (*SqlCnd) Ending

func (s *SqlCnd) Ending(column string, str string) *SqlCnd

func (*SqlCnd) Eq

func (s *SqlCnd) Eq(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) Find

func (s *SqlCnd) Find(db *gorm.DB, out interface{})

func (*SqlCnd) FindOne

func (s *SqlCnd) FindOne(db *gorm.DB, out interface{}) errors.WTError

func (*SqlCnd) Gt

func (s *SqlCnd) Gt(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) Gte

func (s *SqlCnd) Gte(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) In

func (s *SqlCnd) In(column string, params interface{}) *SqlCnd

func (*SqlCnd) Like

func (s *SqlCnd) Like(column string, str string) *SqlCnd

func (*SqlCnd) Limit

func (s *SqlCnd) Limit(limit int) *SqlCnd

func (*SqlCnd) Lt

func (s *SqlCnd) Lt(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) Lte

func (s *SqlCnd) Lte(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) NotEq

func (s *SqlCnd) NotEq(column string, args ...interface{}) *SqlCnd

func (*SqlCnd) Page

func (s *SqlCnd) Page(page, limit int) *SqlCnd

func (*SqlCnd) Starting

func (s *SqlCnd) Starting(column string, str string) *SqlCnd

func (*SqlCnd) Where

func (s *SqlCnd) Where(query string, args ...interface{}) *SqlCnd

Jump to

Keyboard shortcuts

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