search

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Equals             Operator = "eq"
	NotEquals          Operator = "neq"
	GreaterThan        Operator = "gt"
	GreaterThanOrEqual Operator = "gte"
	LessThan           Operator = "lt"
	LessThanOrEqual    Operator = "lte"

	Between    Operator = "between"
	NotBetween Operator = "notBetween"

	In    Operator = "in"
	NotIn Operator = "notIn"

	IsNull    Operator = "isNull"
	IsNotNull Operator = "isNotNull"

	Contains      Operator = "contains"
	NotContains   Operator = "notContains"
	StartsWith    Operator = "startsWith"
	NotStartsWith Operator = "notStartsWith"
	EndsWith      Operator = "endsWith"
	NotEndsWith   Operator = "notEndsWith"

	ContainsIgnoreCase      Operator = "iContains"
	NotContainsIgnoreCase   Operator = "iNotContains"
	StartsWithIgnoreCase    Operator = "iStartsWith"
	NotStartsWithIgnoreCase Operator = "iNotStartsWith"
	EndsWithIgnoreCase      Operator = "iEndsWith"
	NotEndsWithIgnoreCase   Operator = "iNotEndsWith"

	TagSearch = "search"

	AttrDive     = "dive"
	AttrAlias    = "alias"
	AttrColumn   = "column"
	AttrOperator = "operator"
	AttrParams   = "params"

	ParamDelimiter = "delimiter"
	ParamType      = "type"

	IgnoreField = "-"

	// Type tokens for schema field type identification.
	TypeInt      = "int"
	TypeDecimal  = "dec"
	TypeDate     = "date"
	TypeDateTime = "datetime"
	TypeTime     = "time"
)

Variables

This section is empty.

Functions

func Applier

func Applier[T any]() func(T) orm.ApplyFunc[orm.ConditionBuilder]

Types

type Operator

type Operator string
type Search struct {
	// contains filtered or unexported fields
}

Search is a compiled set of search conditions parsed from a struct's `search` tags. Apply it against a populated instance of that struct to translate non-empty fields into ORM query conditions.

func New

func New(typ reflect.Type) Search

New compiles the `search` tags of typ (after dereferencing pointers) into a Search. A non-struct typ is a programming error; it is logged and an empty Search is returned, whose Apply is a no-op.

func NewFor

func NewFor[T any]() Search

NewFor compiles the `search` tags of the struct type T into a Search.

func (Search) Apply

func (f Search) Apply(cb orm.ConditionBuilder, target any, defaultAlias ...string)

Apply adds a query condition for every non-empty field of target, which must be the (optionally pointer-wrapped) struct the Search was built from. The optional defaultAlias qualifies columns that do not declare their own alias. A non-struct target is a programming error; it is logged and Apply becomes a no-op, adding no conditions, so callers must not rely on it to enforce filtering.

Jump to

Keyboard shortcuts

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