expr

package
v0.159.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

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

type IntField

type IntField = field[int64]

IntField is the struct field type for integer search parameters. Assign values via expr.Int(...) for exact match or expr.Int.X(...) for lookups.

type UserSearchParams struct {
    Uid expr.IntField `json:"uid,omitempty"`
}

type StrField

type StrField = field[string]

StrField is the struct field type for string search parameters. Assign values via expr.Str(...) for exact match or expr.Str.X(...) for lookups.

type UserSearchParams struct {
    Name expr.StrField `json:"name,omitempty"`
}

Jump to

Keyboard shortcuts

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