filter

package
v0.24.4 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MemoFilterCELAttributes = []cel.EnvOption{
	cel.Variable("content", cel.StringType),
	cel.Variable("creator_id", cel.IntType),
	cel.Variable("created_ts", cel.IntType),
	cel.Variable("updated_ts", cel.IntType),
	cel.Variable("pinned", cel.BoolType),
	cel.Variable("tag", cel.StringType),
	cel.Variable("visibility", cel.StringType),
	cel.Variable("has_task_list", cel.BoolType),

	cel.Function("now",
		cel.Overload("now",
			[]*cel.Type{},
			cel.IntType,
			cel.FunctionBinding(func(_ ...ref.Val) ref.Val {
				return types.Int(time.Now().Unix())
			}),
		),
	),
}

MemoFilterCELAttributes are the CEL attributes for memo.

Functions

func GetConstValue

func GetConstValue(expr *exprv1.Expr) (any, error)

GetConstValue returns the constant value of the expression.

func GetExprValue added in v0.24.4

func GetExprValue(expr *exprv1.Expr) (any, error)

GetExprValue attempts to get a value from an expression, trying constants first, then functions.

func GetFunctionValue added in v0.24.4

func GetFunctionValue(expr *exprv1.Expr) (any, error)

GetFunctionValue evaluates CEL function calls and returns their value. This is specifically for time functions like now().

func GetIdentExprName

func GetIdentExprName(expr *exprv1.Expr) (string, error)

GetIdentExprName returns the name of the identifier expression.

func Parse

func Parse(filter string, opts ...cel.EnvOption) (expr *exprv1.ParsedExpr, err error)

Parse parses the filter string and returns the parsed expression. The filter string should be a CEL expression.

Types

type ConvertContext

type ConvertContext struct {
	Buffer strings.Builder
	Args   []any
	// The offset of the next argument in the condition string.
	// Mainly using for PostgreSQL.
	ArgsOffset int
}

func NewConvertContext

func NewConvertContext() *ConvertContext

Jump to

Keyboard shortcuts

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