query

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyFieldMapper = make(FieldMapper)

Functions

This section is empty.

Types

type Distinct added in v0.2.8

type Distinct struct {
	Field Field
}

func (Distinct) OptionType added in v0.2.8

func (d Distinct) OptionType() OptionType

type Field

type Field string

func (Field) Ascending

func (f Field) Ascending() *Order

func (Field) Descending

func (f Field) Descending() *Order

func (Field) Distinct added in v0.2.8

func (f Field) Distinct() *Distinct

func (Field) Equal

func (f Field) Equal(value interface{}) *Filter

func (Field) GreaterOrEqual

func (f Field) GreaterOrEqual(value interface{}) *Filter

func (Field) GreaterThan

func (f Field) GreaterThan(value interface{}) *Filter

func (Field) LessOrEqual

func (f Field) LessOrEqual(value interface{}) *Filter

func (Field) LessThan

func (f Field) LessThan(value interface{}) *Filter

func (Field) NotEqual

func (f Field) NotEqual(value interface{}) *Filter

type FieldMapper

type FieldMapper map[Field]string

func (*FieldMapper) Get

func (m *FieldMapper) Get(field Field) string

func (*FieldMapper) Map added in v0.2.10

func (m *FieldMapper) Map(fields []Field) []string

type Filter

type Filter struct {
	Field    Field
	Operator Operator
	Value    interface{}
}

func (*Filter) OptionType

func (f *Filter) OptionType() OptionType

type Logical

type Logical struct {
	Operator LogicalOperator
	Filters  []Option // Filter or Logical
}

func And

func And(filters ...Option) *Logical

func Not

func Not(filter Option) *Logical

func Or

func Or(filters ...Option) *Logical

func (*Logical) OptionType

func (l *Logical) OptionType() OptionType

type LogicalOperator

type LogicalOperator string
const (
	OpAnd LogicalOperator = "and"
	OpOr  LogicalOperator = "or"
	OpNot LogicalOperator = "not"
)

type Operator

type Operator string
const (
	OpEqual          Operator = "eq"
	OpNotEqual       Operator = "ne"
	OpGreater        Operator = "gt"
	OpGreaterOrEqual Operator = "gte"
	OpLess           Operator = "lt"
	OpLessOrEqual    Operator = "lte"
)

type Option

type Option interface {
	OptionType() OptionType
}

Option is an interface.

type OptionType

type OptionType int
const (
	OptionTypeFilter OptionType = iota
	OptionTypeLogical
	OptionTypeSort
	OptionTypeDistinct
)

type Order

type Order struct {
	Field Field
	Order SortOrder
}

func (Order) OptionType

func (o Order) OptionType() OptionType

type QueryBuilder

type QueryBuilder[T any] interface {
	Build(options ...Option) T
	WithFieldMapper(mapper FieldMapper) QueryBuilder[T]
}

QueryBuilder is a function that takes a filter and returns a new filter

type SortOrder

type SortOrder int
const (
	Ascending SortOrder = iota
	Descending
)

Jump to

Keyboard shortcuts

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