query

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NodeCondition = 1
	LinkCondition = 2
)

Variables

This section is empty.

Functions

func ExecuteQuery

func ExecuteQuery(query *Query, config *configuration.Config) (configuration.Config, error)

ExecuteQuery filters the configuration based on the provided query. It returns a new configuration containing only the nodes and links that match the query conditions.

Types

type Condition

type Condition struct {
	Field      string      `yaml:"field"`
	Operator   string      `yaml:"operator"`
	Value      string      `yaml:"value"`
	Conditions []Condition `yaml:"conditions"`
}

type ConfigContext

type ConfigContext struct {
	Config      *configuration.Config
	NodesById   map[string]*configuration.Node
	ChildrenMap map[string][]string // Maps parent node ID to list of child node IDs
}

ConfigContext holds the configuration with pre-calculated maps for efficient querying

func NewConfigContext

func NewConfigContext(config *configuration.Config) *ConfigContext

NewConfigContext creates a new ConfigContext with pre-calculated maps for efficient querying

type Filter

type Filter struct {
	Condition Condition `yaml:"condition"`
}

func (*Filter) Validate

func (filter *Filter) Validate(filterType int) error

Validate checks if the filter is valid.

type Links struct {
	Filters []Filter `yaml:"filters"`
}

type Nodes

type Nodes struct {
	Filters []Filter `yaml:"filters"`
}

func (*Nodes) Validate

func (nodes *Nodes) Validate() error

Validate checks if the nodes are valid.

type Query

type Query struct {
	Nodes Nodes `yaml:"nodes"`
	Links Links `yaml:"links"`
}

func LoadQuery

func LoadQuery(filepath string) (*Query, error)

LoadQuery loads the query from a YAML file.

func ParseQuery

func ParseQuery(queryStr string) (*Query, error)

ParseQuery parses a query from a YAML string.

func (*Query) Validate

func (q *Query) Validate() error

Validate checks if the query is valid.

func (*Query) YamlString

func (q *Query) YamlString() string

YamlString returns the YAML representation of the query

Jump to

Keyboard shortcuts

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