query_parser

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDBKeyName added in v0.15.0

func GetDBKeyName(v interface{}) (string, error)

func Overlap

func Overlap(param interface{}, key string, notEq bool) (r sq.Sqlizer, err error)

Overlap is used to check if two arrays overlap (SQL operator &&). But can also be used as the ANY operator in SQL to check if a string/number is in an array.

func ParseFilterParam

func ParseFilterParam(params string, allowedColumns []string) (f sq.Sqlizer, err error)

func ParseOrderParams

func ParseOrderParams(params string, allowedColumns []string) ([]string, error)

Types

type Filter

type Filter struct {
	FuncName  string      `json:"funcName"`
	Key       string      `json:"key"`
	Parameter interface{} `json:"parameter"`
}

type FilterCategoryType added in v0.16.16

type FilterCategoryType string
const (
	Number   FilterCategoryType = "number"
	String   FilterCategoryType = "string"
	Date     FilterCategoryType = "date"
	Boolean  FilterCategoryType = "boolean"
	Array    FilterCategoryType = "array"
	Duration FilterCategoryType = "duration"
	Enum     FilterCategoryType = "enum"
	Tag      FilterCategoryType = "tag"
)

type FilterClauses

type FilterClauses struct {
	And    []FilterClauses `json:"$and"`
	Or     []FilterClauses `json:"$or"`
	Filter Filter          `json:"$filter"`
}

type Order

type Order struct {
	Key       string `json:"key"`
	Direction string `json:"direction"`
}

type Parameter

type Parameter string

type QueryParser

type QueryParser struct {
	AllowedColumns []string
}

func NewParser

func NewParser(allowedColumns []string) *QueryParser

func (*QueryParser) IsAllowed

func (qp *QueryParser) IsAllowed(c string) bool

func (*QueryParser) ParseFilter

func (qp *QueryParser) ParseFilter(f Filter) (r sq.Sqlizer, err error)

func (*QueryParser) ParseFilterClauses

func (qp *QueryParser) ParseFilterClauses(f FilterClauses) (d sq.Sqlizer, err error)

func (*QueryParser) ParseOrder

func (qp *QueryParser) ParseOrder(s Order) (r string, err error)

func (*QueryParser) ParseOrderClauses

func (qp *QueryParser) ParseOrderClauses(s []Order) (r []string, err error)

Jump to

Keyboard shortcuts

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