query

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

The query package provides the functionality to query records. By using reflections the package is structure-agnostic.

Index

Constants

This section is empty.

Variables

View Source
var AccQueryables = Queryables{
	{
		Name: "customer",
		Type: schema.Party{},
	},
	{
		Name: "employee",
		Type: schema.Party{},
	},
	{
		Name: "expense",
		Type: schema.Expense{},
	},
	{
		Name: "invoice",
		Type: schema.Invoice{},
	},
	{
		Name: "misc-record",
		Type: schema.MiscRecord{},
	},
	{
		Name: "project",
		Type: schema.Project{},
	},
	{
		Name: "transaction",
		Type: schema.Transaction{},
	},
}

Functions

This section is empty.

Types

type DateTerm

type DateTerm struct {
	Key  *regexp.Regexp
	From time.Time
	To   time.Time
}

type DateTerms

type DateTerms []DateTerm

type Element

type Element []KeyValue

func NewElement

func NewElement(v reflect.Value) Element

func (Element) DateMatch

func (e Element) DateMatch(ranges DateTerms) bool

func (Element) Match

func (e Element) Match(terms SearchTerms, caseSensitive bool) bool

func (Element) MaxKeyLength

func (e Element) MaxKeyLength() int

func (Element) Select

func (e Element) Select(sel []string, caseSensitive bool) Element

type ElementGroup

type ElementGroup []Element

func NewElements

func NewElements(ele interface{}) ElementGroup

func (ElementGroup) DateMatch

func (g ElementGroup) DateMatch(ranges DateTerms) ElementGroup

func (ElementGroup) MatchTerm

func (g ElementGroup) MatchTerm(terms SearchTerms, caseSensitive bool) ElementGroup

func (ElementGroup) Select

func (g ElementGroup) Select(sel []string, caseSensitive bool) ElementGroup

type Key

type Key struct {
	Name       string
	Queryables Queryables
}

type KeyValue

type KeyValue struct {
	Key   string
	Value string
	Field reflect.StructField
}

func (KeyValue) RenderValue

func (k KeyValue) RenderValue(s schema.Schema) string

type Keys

type Keys []Key

func (Keys) Add

func (k Keys) Add(key Key) Keys

func (Keys) Data

func (k Keys) Data() []KeyValue

type Output

type Output struct {
	Header  []string
	Element Element
}

func NewOutput

func NewOutput(s schema.Schema, ele Element) Output

func (Output) OpenAttachment

func (o Output) OpenAttachment()

func (Output) PPKeyValue

func (o Output) PPKeyValue(a *schema.Schema, mode OutputMode, render bool)

type OutputMode

type OutputMode int
const (
	YamlMode OutputMode = iota
	TableMode
)

type Outputs

type Outputs []Output

func OutputsFromElements

func OutputsFromElements(s schema.Schema, ele []Element) Outputs

func (Outputs) PPKeyValue

func (o Outputs) PPKeyValue(s schema.Schema, mode OutputMode, render, openAttachment bool)

type Queryable

type Queryable struct {
	Name string
	Type interface{}
}

type Queryables

type Queryables []Queryable

func (Queryables) PPKeys

func (q Queryables) PPKeys(mode OutputMode)

func (Queryables) PPTypes

func (q Queryables) PPTypes()

func (Queryables) QueryAcc

func (q Queryables) QueryAcc(s schema.Schema, termsInput, dateInput, selectInput string, mode OutputMode, render, caseSensitive, openAttachment bool)

func (Queryables) QueryablesFromUserInput

func (q Queryables) QueryablesFromUserInput(input string) (Queryables, error)

func (Queryables) String

func (q Queryables) String() string

func (Queryables) Types

func (q Queryables) Types() []string

type SearchTerm

type SearchTerm struct {
	Key   *regexp.Regexp
	Value *regexp.Regexp
}

type SearchTerms

type SearchTerms []SearchTerm

Jump to

Keyboard shortcuts

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