Documentation
¶
Overview ¶
Package expr provides typed query field expressions for the VMS typed REST API.
expr.Str — callable factory for string search fields (call = exact match) expr.Int — callable factory for integer search fields (call = exact match) expr.StrField — field type to use in *SearchParams structs for string params expr.IntField — field type to use in *SearchParams structs for integer params
Usage:
type UserSearchParams struct {
Name expr.StrField `json:"name,omitempty"`
Uid expr.IntField `json:"uid,omitempty"`
}
UserSearchParams{Name: expr.Str("admin")} // ?name=admin
UserSearchParams{Name: expr.Str.StartsWith("sys")} // ?name__startswith=sys
UserSearchParams{Uid: expr.Int(42)} // ?uid=42
UserSearchParams{Uid: expr.Int.GT(1000)} // ?uid__gt=1000
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Int = intOp(func(v int64) IntField {
return exactField(v)
})
Int is a callable factory for integer search field expressions. Calling it directly produces an exact-match field; methods produce lookups.
type UserSearchParams struct {
Uid expr.IntField `json:"uid,omitempty"`
}
UserSearchParams{Uid: expr.Int(42)} // ?uid=42
UserSearchParams{Uid: expr.Int.GT(1000)} // ?uid__gt=1000
UserSearchParams{Uid: expr.Int.GTE(1000)} // ?uid__gte=1000
UserSearchParams{Uid: expr.Int.In(1, 2, 3)} // ?uid__in=1,2,3 (PK fields only)
UserSearchParams{Uid: expr.Int.NotGTE(9999)} // ?uid__not_gte=9999
View Source
var Str = strOp(func(v string) StrField {
return exactField(v)
})
Str is a callable factory for string search field expressions. Calling it directly produces an exact-match field; methods produce lookups.
type UserSearchParams struct {
Name expr.StrField `json:"name,omitempty"`
}
UserSearchParams{Name: expr.Str("admin")} // ?name=admin
UserSearchParams{Name: expr.Str.StartsWith("sys")} // ?name__startswith=sys
UserSearchParams{Name: expr.Str.IContains("adm")} // ?name__icontains=adm
UserSearchParams{Name: expr.Str.Regex(`^sys\d+`)} // ?name__regex=^sys\d+
UserSearchParams{Name: expr.Str.In("alice", "bob")} // ?name__in=alice,bob
UserSearchParams{Name: expr.Str.NotContains("test")} // ?name__not_contains=test
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.