rsql

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mongo

func Mongo() func(parser *Parser) error

Mongo adds the default mongo operators to the parser

func Mysql

func Mysql() func(parser *Parser) error

func MysqlPre

func MysqlPre(nameTransfer func(s string) string) func(parser *PreParser) error

func SetAllowedKeys

func SetAllowedKeys(keys []string) func(opts *ProcessOptions) error

SetAllowedKeys set's the keys which can be used for querying.

func SetForbiddenKeys

func SetForbiddenKeys(keys []string) func(opts *ProcessOptions) error

SetForbiddenKeys set's the keys which must not be used for querying.

func WithKeyTransformers

func WithKeyTransformers(transformers ...func(string) string) func(parser *Parser) error

WithKeyTransformers adds functions to alter key names in any way.

func WithOperators

func WithOperators(operators ...Operator) func(parser *Parser) error

WithOperator adds custom operators to the parser

Types

type Operator

type Operator struct {
	Operator  string
	Formatter func(key, value string) string
}

Operator represents a query Operator. It defines the Operator itself, the mongodb representation of the Operator and if it is a list Operator or not. Operators must match regex reOperator: `(!|=)[^=()]*=`

type Parser

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

Parser represents a RSQL parser.

func NewParser

func NewParser(options ...func(*Parser) error) (*Parser, error)

NewParser returns a new rsql server.

func (*Parser) Process

func (parser *Parser) Process(s string, options ...func(*ProcessOptions) error) (string, error)

Process takes the given string and processes it using parser's operators.

type PreOperator

type PreOperator struct {
	Operator  string
	Formatter func(key string) string
}

type PreParser

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

PreParser represents a RSQL parser to generate prepare statement.

func NewPreParser

func NewPreParser(options ...func(*PreParser) error) (*PreParser, error)

NewParser returns a new rsql server.

func (*PreParser) ProcessPre

func (parser *PreParser) ProcessPre(s string, options ...func(*ProcessOptions) error) (string, []interface{}, error)

type ProcessOptions

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

ProcessOptions contains options for the parser's Process function.

Jump to

Keyboard shortcuts

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