advanced_search

package
v1.96.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdvancedSearch

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

AdvancedSearch represents the advanced search query

func NewAdvancedSearch

func NewAdvancedSearch(query string) *AdvancedSearch

NewAdvancedSearch creates a new instance of AdvancedSearch

func (*AdvancedSearch) Parse

func (as *AdvancedSearch) Parse() ([]Clause, []SortClause, error)

Parse parses the query string and returns a slice of Clause objects

type AdvancedSqlSearch

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

AdvancedSqlSearch extends the AdvancedSearch with column definitions

func NewAdvancedSqlSearch

func NewAdvancedSqlSearch(query string, columns ...Column) (*AdvancedSqlSearch, error)

NewAdvancedSqlSearch creates a new instance of AdvancedSqlSearch

func (*AdvancedSqlSearch) SortStatement added in v1.46.0

func (as *AdvancedSqlSearch) SortStatement() (string, error)

SortStatement generates the SQL ORDER BY clause

func (*AdvancedSqlSearch) Sql

func (as *AdvancedSqlSearch) Sql() (string, string, error)

Sql generates both the WHERE and ORDER BY clauses

func (*AdvancedSqlSearch) WhereStatement added in v1.46.0

func (as *AdvancedSqlSearch) WhereStatement() (string, error)

WhereStatement generates the SQL WHERE clause

type Clause

type Clause struct {
	Field    string
	Operator Operator
	Value    string
}

Clause represents a single SQL WHERE clause

func NewClause

func NewClause(field string, operator Operator, value string) Clause

func (Clause) Sql

func (c Clause) Sql(name string) string

type Column added in v1.46.0

type Column struct {
	Name    string
	Type    ColumnType
	Aliases []string
}

Column represents a column in the database with a name, type, and possible aliases

type ColumnType added in v1.46.0

type ColumnType int

ColumnType represents the type of a column in the database

const (
	StringType ColumnType = iota
	IntType
	FloatType
	BoolType
	DateType
	DateTimeType
)

type Direction added in v1.45.0

type Direction int
const (
	Asc Direction = iota
	Desc
)

type Operator

type Operator int

Operator represents the type for SQL operators

const (
	Equal Operator = iota
	NotEqual
	GreaterThan
	GreaterThanOrEqual
	LessThan
	LessThanOrEqual
	Null
	NotNull
	Like
	UnknownOperator
)

func (Operator) String

func (o Operator) String() string

String returns the string representation of the Operator

type ParseError

type ParseError struct {
	Part  string
	Cause string
}

ParseError represents a parsing error with context

func (*ParseError) Error

func (e *ParseError) Error() string

type SortClause added in v1.45.0

type SortClause struct {
	Field     string
	Direction Direction
}

Jump to

Keyboard shortcuts

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