query

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const FilterKey = "__sb_query__"

Variables

This section is empty.

Functions

func IsComparison

func IsComparison(op Operator) bool

func ValidateField

func ValidateField(field string) error

Types

type Clause

type Clause struct {
	Field    string
	Operator Operator
	Value    Operand
}

type Operand

type Operand struct {
	Kind  OperandKind
	Field string
	Value any
	Type  ValueType
}

func ParseOperand

func ParseOperand(v any) (Operand, error)

type OperandKind

type OperandKind int
const (
	OperandLiteral OperandKind = iota
	OperandField
)

type Operator

type Operator string
const (
	OpEqual       Operator = "="
	OpNotEqual    Operator = "!="
	OpGreater     Operator = ">"
	OpLower       Operator = "<"
	OpGreaterEq   Operator = ">="
	OpLowerEq     Operator = "<="
	OpIn          Operator = "in"
	OpNotIn       Operator = "!in"
	OpContains    Operator = "contains"
	OpNotContains Operator = "!contains"
)

func ParseOperator

func ParseOperator(op string) (Operator, error)

type Query

type Query []Clause

func FromFilter

func FromFilter(filter map[string]interface{}) (Query, bool)

func Parse

func Parse(clauses [][]interface{}) (Query, error)

type ValueType

type ValueType string
const (
	TypeDefault ValueType = ""
	TypeNumber  ValueType = "number"
	TypeBoolean ValueType = "boolean"
)

func InferValueType

func InferValueType(v any) ValueType

Jump to

Keyboard shortcuts

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