query

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParsed = errors.New("text parsed")
View Source
var PrimitiveTypes = []Token{
	TNumber,
	TString,
	TRegex,
	TBool,
}
View Source
var PrimitiveTypesAndKey = append(PrimitiveTypes, TKey)

Functions

func IsPrimitive

func IsPrimitive(t Token) bool

func IsPrimitiveOrKey

func IsPrimitiveOrKey(t Token) bool
func Link(n *Node)

Types

type CompiledQuery

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

func Compile

func Compile(query string, params ...interface{}) (CompiledQuery, error)

func MustCompile

func MustCompile(query string, params ...interface{}) CompiledQuery

func (CompiledQuery) Discard

func (pq CompiledQuery) Discard()

func (CompiledQuery) MarshalBSON

func (pq CompiledQuery) MarshalBSON() ([]byte, error)

type Expression

type Expression struct {
	Op    string
	L     []byte
	LT    ValueType
	R     []byte
	RT    ValueType
	S, T  pos
	Links *[]*Expression
}

func (*Expression) FindKey

func (e *Expression) FindKey() []byte

func (*Expression) String

func (e *Expression) String() string

type Node

type Node struct {
	Parent *Node
	In     *NodeContext
	Op     string
	L, R   *Expression
	LN, RN *Node
	LRoot  bool
}

func Reduce

func Reduce(n *Node) *Node

func (*Node) FixParent

func (n *Node) FixParent()

func (*Node) LocalRoot

func (n *Node) LocalRoot() (*Node, bool)

LocalRoot finds local root (parent node for parentheses) and flag if we found local root from left side.

func (*Node) Replace

func (n *Node) Replace(on, nn *Node)

func (*Node) ReplaceNode

func (n *Node) ReplaceNode(nn *Node)

func (*Node) Root

func (n *Node) Root() *Node

func (*Node) SetNextExpression

func (n *Node) SetNextExpression(ne *Expression)

func (*Node) SetNextNode

func (n *Node) SetNextNode(nn *Node)

func (*Node) String

func (n *Node) String() string

type NodeContext

type NodeContext struct {
	Field []byte
}

type Parser

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

func NewParser

func NewParser(s *Scanner) *Parser

func (*Parser) Parse

func (p *Parser) Parse() (*Node, error)

type PreparedQuery

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

func MustPrepare

func MustPrepare(query string) *PreparedQuery

func Prepare

func Prepare(query string) (*PreparedQuery, error)

func (PreparedQuery) Compile

func (enc PreparedQuery) Compile(params ...interface{}) (CompiledQuery, error)

type Scanner

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

func NewScanner

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Next

func (s *Scanner) Next() error

func (*Scanner) Position

func (s *Scanner) Position() (int, int)

func (*Scanner) Token

func (s *Scanner) Token() (Token, []byte)

type Token

type Token uint
const (
	TKey Token = iota + 1
	TNumber
	TString
	TOp
	TParentheses
	TRegex
	TBool
	TComma
)

type ValueType

type ValueType uint
const (
	VTKey ValueType = iota + 1
	VTInteger
	VTFloat
	VTString
	VTRegex
	VTDate
	VTObjectID
	VTBool
	VTArray
)

Jump to

Keyboard shortcuts

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