config

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenTemplate

func GenTemplate(objName string) (string, error)

Types

type Mutation

type Mutation struct {
	XMLName       xml.Name `xml:"mutation"`
	Name          string   `xml:"name,attr"`
	InvalidateStr string   `xml:"invalidate,attr"`
	SQL           SQLStmt  `xml:"sql"`
}

Mutation are one of Insert/Update/Delete

func (Mutation) InvalidateQueries

func (m Mutation) InvalidateQueries() []string

InvalidateQueries - query names

func (Mutation) IsValid

func (m Mutation) IsValid() error

IsValid - return nil if valid.

type NeedleConfig

type NeedleConfig struct {
	XMLName xml.Name `xml:"needle"`
	Schema  Schema   `xml:"schema"`
	Stmts   Stmts    `xml:"stmts"`
}

NeedleConfig the root structure of a needle xml config file

func ParseConfigFromFile

func ParseConfigFromFile(path string) (*NeedleConfig, error)

ParseConfigFromFile -

type Query

type Query struct {
	XMLName          xml.Name `xml:"query"`
	Name             string   `xml:"name,attr"`
	Type             string   `xml:"type,attr"`
	CacheDurationStr string   `xml:"cacheDuration,attr"`
	SQL              SQLStmt  `xml:"sql"`
}

Query is the type of select statement.

func (Query) CacheDuration

func (q Query) CacheDuration() *time.Duration

CacheDuration cache duration of query result. nil = nocache 0 time.Duration indicates cache forever.

func (Query) IsSingleRow

func (q Query) IsSingleRow() bool

IsSingleRow whether the result of query is single row or many row.

func (Query) IsValid

func (q Query) IsValid() error

IsValid nil if Query is valid.

type Reference

type Reference struct {
	Src string `xml:"src,attr"`
	SQL SQLStmt
}

Reference is imported schemas. stmts like join may need stmts from others. SQL is set after importing from source.

type SQLStmt

type SQLStmt string

SQLStmt is just a string.

func (SQLStmt) Parse

func (s SQLStmt) Parse() (ast.StmtNode, error)

Parse - yes, parse it. Although parser is heavy, needle is not performance sensitive, so...

type Schema

type Schema struct {
	HiddenFieldsStr string      `xml:"hiddenFields,attr"`
	Name            string      `xml:"name,attr"`
	MainObj         string      `xml:"mainObj,attr"`
	SQL             SQLStmt     `xml:"sql"`
	Refs            []Reference `xml:"ref"`
}

Schema schema of this config and imported sources.

func (Schema) HiddenFields

func (s Schema) HiddenFields() []string

HiddenFields return hidden fields of this schema.

func (Schema) IsValid

func (s Schema) IsValid() error

IsValid return nil if valid.

type Stmts

type Stmts struct {
	Queries   []Query    `xml:"query"`
	Mutations []Mutation `xml:"mutation"`

	QueryMap    map[string]*Query
	MutationMap map[string]*Mutation
}

Stmts -

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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