queryutil

package
v0.0.50 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 10 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

func NewScopeWithoutValue added in v0.0.40

func NewScopeWithoutValue(conditionSQL string) func(*gorm.DB) *gorm.DB

NewScopeWithoutValue create new scope

Types

type KeyWord added in v0.0.37

type KeyWord struct {
	SearchBy      string
	PageNum       string
	PageSize      string
	OrderBy       string
	PaginationOff string
}

KeyWord query utils key work definition

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
	RemotePreloadlist []RemotePreloader
	// 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 {
	RemotePreloadlist() []RemotePreloader
	PageSize() int
	PageNum() int
	IsPaginationOff() bool
	HandleDBBackend() []func(*gorm.DB) *gorm.DB
	HandleWithPagination(query string) []func(*gorm.DB) *gorm.DB
	Handle(query string) []func(*gorm.DB) *gorm.DB
	HandleRemotePreloader(interface{}) error
}

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

type RemotePreloader added in v0.0.35

type RemotePreloader struct {
	Column      string
	PreloadFunc func(args interface{}, Conditions ...string) (interface{}, error)
	Condition   string
}

RemotePreloader preload the model from remote resource

Jump to

Keyboard shortcuts

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