Back to godoc.org

Package basemodel

v1.6.2
Latest Go to latest
Published: Jul 21, 2020 | License: MIT | Module: github.com/hulklab/yago

Index

Package Files

type BaseModel

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

func (*BaseModel) GetSession

func (m *BaseModel) GetSession() *xorm.Session

func (*BaseModel) Init

func (m *BaseModel) Init(opts ...Option)

func (*BaseModel) PageList

func (m *BaseModel) PageList(query *PageQuery, items interface{}) (int64, error)

List with page

type Filters

type Filters map[string]List

type List

type List []interface{}

Funnel screening condition For example, "filters":{"user_state":[0,1],"phone_state":[0]} means "where user_state in(0,1) and phone_state = 0"

type Option

type Option func(o *Options)

func WithCtx

func WithCtx(ctx context.Context) Option

func WithDefaultOrder

func WithDefaultOrder(orders ...Order) Option

func WithDefaultPageSize

func WithDefaultPageSize(page, size int) Option

func WithSession

func WithSession(session *xorm.Session) Option

type Options

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

type Order

type Order map[string]int

Order condition 1 = ASC, -1 = DESC For example, "orders":[{"created_at":1},{"id":-1}] means "order by created_at asc, id desc"

type Orders

type Orders []Order

type PageQuery

type PageQuery struct {
	Page       int
	Size       int
	Q          Q
	Filters    Filters
	Orders     Orders
	ExtraQuery QueryHandler
}

List query with page For example, {

"page": 1,
"size": 20,
"q": "x",
"orders": [
  {
    "created_at": 1
  },
  {
    "id": -1
  }
],
"filters": {
  "user_state": [
    0,
    1
  ],
  "phone_state": [
    0
  ]
}

}

type Q

type Q map[string][]string

Fuzzy search For example, "sheldon": []string{"username", "phone"} means "username like %sheldon% or phone like %sheldon%"

type Query

type Query struct {
	Q          Q
	Filters    Filters
	Orders     Orders
	ExtraQuery QueryHandler
}

List query without page

type QueryHandler

type QueryHandler func(session *xorm.Session)
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier