predicate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 6

Documentation

Overview

Package predicate defines public predicate templates, filters, and custom handler contracts. Runtime compilation and SQL expansion remain Datly-owned.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterTemplate

func RegisterTemplate(template *Template)

func Templates

func Templates(callback NotifierFn) (map[string]*Template, func())

Types

type BoolFilter

type BoolFilter struct {
	Include []bool `json:",omitempty"`
	Exclude []bool `json:",omitempty"`
}

BoolFilter is the reduced bool filter payload shape.

type Criteria added in v1.0.0

type Criteria struct {
	Expression   string
	Placeholders []any
}

Criteria is the SQL fragment produced by a custom predicate handler.

type Handler added in v1.0.0

type Handler interface {
	Compute(context.Context, any) (*Criteria, error)
}

Handler computes one predicate fragment from a bound input value.

type HandlerFunc added in v1.0.0

type HandlerFunc func(context.Context, any) (*Criteria, error)

HandlerFunc adapts a function to Handler.

func (HandlerFunc) Compute added in v1.0.0

func (f HandlerFunc) Compute(ctx context.Context, value any) (*Criteria, error)

type IntFilter

type IntFilter struct {
	Include []int `json:",omitempty"`
	Exclude []int `json:",omitempty"`
}

IntFilter is the reduced int filter payload shape.

type Lookup added in v1.0.0

type Lookup interface {
	Lookup(name string) (*Template, error)
}

Lookup defines the minimal read-only predicate-template registry contract.

type NamedArgument

type NamedArgument struct {
	Name     string
	Position int
}

NamedArgument describes one named template argument.

type NamedFilter

type NamedFilter struct {
	Name    string   `xls:"name=Filter"`
	Include []string `json:",omitempty"`
	Exclude []string `json:",omitempty"`
}

NamedFilter groups include/exclude values under one named filter.

type NamedFilters

type NamedFilters []*NamedFilter

NamedFilters is the reduced public filter payload contract.

type NotifierFn

type NotifierFn func(template *Template)

type Registry

type Registry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func New

func New() *Registry

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (*Template, error)

type StringsFilter

type StringsFilter struct {
	Include []string `json:",omitempty"`
	Exclude []string `json:",omitempty"`
}

StringsFilter is the reduced string filter payload shape.

type Template

type Template struct {
	Name   string
	Source string
	Args   []*NamedArgument
}

Template is the public predicate-template contract.

Jump to

Keyboard shortcuts

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