queryutil

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewScope added in v0.0.31

func NewScope(conditionSQL string, valueSQL interface{}) func(*gorm.DB) *gorm.DB

NewScope create new scope

Types

type QueryConfig

type QueryConfig struct {
	FilterBackend []func(db *gorm.DB) *gorm.DB
	PageSize      int
	SearchByList  []string
	FilterList    []string
	OrderByList   []string
	PreloadList   map[string]func(db *gorm.DB) *gorm.DB
	// SetFilterCustomizeFunc
	// run local
	// option 1 : func(db *gorm.DB, queryValue string) *gorm.DB
	// run remotely
	// option 2 : rpc call --> to do
	//   func(manager interface{}, methodName string) *gorm.DB
	FilterCustomizeFunc map[string]interface{}
	IsDebug             bool
}

QueryConfig query config

func DefaultConfig

func DefaultConfig(tCtx application.Context) *QueryConfig

DefaultConfig with system setting

type QueryDecoder

type QueryDecoder interface {
	ConditionSQL() string
	ValueSQL() interface{}
}

QueryDecoder query decoder

func NewDecoder

func NewDecoder(queryName string, queryValue string) QueryDecoder

NewDecoder new query decoder

type QueryHandler

type QueryHandler interface {
	PageSize() int
	PageNum() int
	HandleDBBackend() []func(*gorm.DB) *gorm.DB
	HandleWithPagination(query string) []func(*gorm.DB) *gorm.DB
	Handle(query string) []func(*gorm.DB) *gorm.DB
}

QueryHandler query handler in query out gorm scopes

func New

func New(config *QueryConfig) QueryHandler

New query handler with customize handler config

func NewWithDefaultConfig

func NewWithDefaultConfig(tCtx application.Context, query string) QueryHandler

NewWithDefaultConfig query handler with default config

Jump to

Keyboard shortcuts

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