Documentation
¶
Index ¶
- func AnyOf[T any](values []T) []any
- type Condition
- type FieldBuilder
- func (fb FieldBuilder) Contains(value any) Condition
- func (fb FieldBuilder) ContainsAll(values ...any) Condition
- func (fb FieldBuilder) ContainsAny(values ...any) Condition
- func (fb FieldBuilder) EndsWith(suffix string) Condition
- func (fb FieldBuilder) Eq(value any) Condition
- func (fb FieldBuilder) Gt(value any) Condition
- func (fb FieldBuilder) Gte(value any) Condition
- func (fb FieldBuilder) HasKey(key string) Condition
- func (fb FieldBuilder) In(values ...any) Condition
- func (fb FieldBuilder) IsNil() Condition
- func (fb FieldBuilder) IsNotNil() Condition
- func (fb FieldBuilder) Lt(value any) Condition
- func (fb FieldBuilder) Lte(value any) Condition
- func (fb FieldBuilder) Ne(value any) Condition
- func (fb FieldBuilder) NotIn(values ...any) Condition
- func (fb FieldBuilder) RegExp(re any) Condition
- func (fb FieldBuilder) StartsWith(prefix string) Condition
- func (fb FieldBuilder) StringContains(substr string) Condition
- type FieldRef
- type LogicType
- type Operator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnyOf ¶ added in v0.11.0
AnyOf converts a typed slice into a []any so it can be spread into In or NotIn without per-call boilerplate. The variadic forms above require the spread either way; this helper closes the typed-slice footgun (`Field("id").In(stringIDs)` would silently match the literal slice value).
Type inference picks T from the argument; no explicit type parameter needed at the call site.
where.Field("id").In(where.AnyOf(stringIDs)...)
where.Field("status").NotIn(where.AnyOf(allStatuses)...)
Go does not allow generic methods on non-generic receivers, so a chained `.InSlice(stringIDs)` form is not possible — this top-level helper is the closest typed-spread the language permits.
Types ¶
type Condition ¶
type Condition interface {
// FieldName returns the target field name, or "" for logical conditions.
FieldName() string
// contains filtered or unexported methods
}
Condition represents a query filter condition.
type FieldBuilder ¶
type FieldBuilder struct {
// contains filtered or unexported fields
}
FieldBuilder provides a fluent API for building field conditions.
func Field ¶
func Field(name string) FieldBuilder
Field starts building a condition on the named field. Supports dot notation for nested fields (e.g. "address.city").
func (FieldBuilder) Contains ¶
func (fb FieldBuilder) Contains(value any) Condition
func (FieldBuilder) ContainsAll ¶
func (fb FieldBuilder) ContainsAll(values ...any) Condition
func (FieldBuilder) ContainsAny ¶
func (fb FieldBuilder) ContainsAny(values ...any) Condition
func (FieldBuilder) EndsWith ¶ added in v0.3.0
func (fb FieldBuilder) EndsWith(suffix string) Condition
EndsWith matches string fields that end with the given suffix.
func (FieldBuilder) Eq ¶
func (fb FieldBuilder) Eq(value any) Condition
func (FieldBuilder) Gt ¶
func (fb FieldBuilder) Gt(value any) Condition
func (FieldBuilder) Gte ¶
func (fb FieldBuilder) Gte(value any) Condition
func (FieldBuilder) HasKey ¶
func (fb FieldBuilder) HasKey(key string) Condition
HasKey checks whether a map field contains the given key.
func (FieldBuilder) In ¶
func (fb FieldBuilder) In(values ...any) Condition
func (FieldBuilder) IsNil ¶
func (fb FieldBuilder) IsNil() Condition
func (FieldBuilder) IsNotNil ¶
func (fb FieldBuilder) IsNotNil() Condition
func (FieldBuilder) Lt ¶
func (fb FieldBuilder) Lt(value any) Condition
func (FieldBuilder) Lte ¶
func (fb FieldBuilder) Lte(value any) Condition
func (FieldBuilder) Ne ¶
func (fb FieldBuilder) Ne(value any) Condition
func (FieldBuilder) NotIn ¶
func (fb FieldBuilder) NotIn(values ...any) Condition
func (FieldBuilder) RegExp ¶
func (fb FieldBuilder) RegExp(re any) Condition
RegExp matches the field value against a compiled regular expression.
func (FieldBuilder) StartsWith ¶ added in v0.3.0
func (fb FieldBuilder) StartsWith(prefix string) Condition
StartsWith matches string fields that start with the given prefix.
func (FieldBuilder) StringContains ¶ added in v0.3.0
func (fb FieldBuilder) StringContains(substr string) Condition
StringContains matches string fields that contain the given substring.
type FieldRef ¶
type FieldRef string
FieldRef references another field for field-vs-field comparisons. Example: where.Field("end").Gt(where.FieldRef("start"))