Documentation
¶
Index ¶
Constants ¶
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 ¶
Types ¶
type Search ¶
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 ¶
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 (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.