data

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateCardinality

func ValidateCardinality(cardinality string) error

ValidateCardinality checks if cardinality is valid

Types

type Cache

type Cache struct {
	Service string //register cache service name
	TTLMs   int
	TTL     time.Duration
}

Cache represents a cache

func (*Cache) Init

func (c *Cache) Init()

Init initialises cache object

type Column

type Column struct {
	Name       string `json:",omitempty"`
	DataType   string `json:",omitempty"`
	Expression string `json:",omitempty"`
}

Column represents view view column

type ColumnMatch

type ColumnMatch struct {
	Column    string
	RefColumn string
}

ColumnMatch represents a column match

type Context

type Context struct {
	context.Context
	View *View
	Db   db.Service
}

Context visit context

func NewContext

func NewContext(ctx context.Context, view *View, db db.Service) *Context

type Criteria

type Criteria struct {
	Expression string   `json:",omitempty"`
	Params     []string `json:",omitempty"`
}

Criteria represents FromFragments criteria

type From

type From struct {
	sql.Fragment
	Fragments []*sql.Fragment
}

type IO

type IO struct {
	DataView    string `json:",omitempty"`
	Key         string `json:",omitempty"`
	CaseFormat  string `json:",omitempty"`
	Cardinality string `json:",omitempty"`
	OmitEmpty   bool   `json:",omitempty"`
}

IO represents view input/output

func (*IO) Init

func (o *IO) Init()

Init initialises Input

func (IO) SetOutput

func (o IO) SetOutput(collection gtly.Collection, output io.Output)

SetOutput sets output with specified cardinality

func (IO) Validate

func (o IO) Validate() error

Validate check if output is valid

type Join

type Join struct {
	Type  string `json:",omitempty"`
	Alias string `json:",omitempty"`
	Table string `json:",omitempty"`
	On    string `json:",omitempty"`
}

Join represent a join

type Meta

type Meta struct {
	Input       []*IO   `json:",omitempty"`
	Output      []*IO   `json:",omitempty"`
	Views       []*View `json:",omitempty"`
	TemplateURL string  `json:",omitempty"`
	// contains filtered or unexported fields
}

Meta represents an abstraction describing view access rules

func (*Meta) ApplyTemplate

func (m *Meta) ApplyTemplate()

ApplyTemplate applies template

func (*Meta) Init

func (m *Meta) Init() error

Init initialises views and outputs.

func (*Meta) SetTemplate

func (m *Meta) SetTemplate(template *Meta)

SetTemplate sets template

func (*Meta) Validate

func (m *Meta) Validate() error

Validate checks if rules are valid

func (*Meta) View

func (m *Meta) View(name string) (*View, error)

View returns a view for supplied name or error

type Parameter

type Parameter struct {
	Name          string      `json:",omitempty"` //placeholder name
	When          string      `json:",omitempty"` //applies binding when criteria is met
	From          string      `json:",omitempty"`
	Type          string      `json:",omitempty"` //Path,QueryString,DataView,Parent
	DataType      string      `json:",o mitempty"`
	ComponentType string      `json:",omitempty"`
	DataView      string      `json:",omitempty"`
	Expression    string      `json:",omitempty"`
	Default       interface{} `json:",omitempty"`
}

Parameter represents view binding

func (*Parameter) Init

func (b *Parameter) Init()

Init initialises binding

func (Parameter) Validate

func (b Parameter) Validate() error

Validate checks if binding is valid

type Pool

type Pool map[string]interface{}

Pool represents a view pool

type Record

type Record map[string]interface{}

Record represent generic record

type Reference

type Reference struct {
	Name        string
	Cardinality string //One, or Many
	DataView    string
	On          []*ColumnMatch
	// contains filtered or unexported fields
}

Reference represents view view reference

func (*Reference) Alias

func (r *Reference) Alias() string

Alias returns alias

func (*Reference) Columns

func (r *Reference) Columns() []string

Columns returns owner match columns

func (*Reference) Criteria

func (r *Reference) Criteria(alias string) string

Criteria reference criteria

func (*Reference) Index

func (r *Reference) Index() gtly.Index

Index returns index

func (*Reference) RefColumns

func (r *Reference) RefColumns() []string

RefColumns returns reference match columns

func (*Reference) RefIndex

func (r *Reference) RefIndex() gtly.Index

RefIndex returns ref index

func (Reference) Validate

func (r Reference) Validate() error

Validate checks if reference is valid

func (*Reference) View

func (r *Reference) View() *View

View returns association view

type Selector

type Selector struct {
	Prefix     string    `json:",omitempty"`
	Columns    []string  `json:",omitempty"`
	Criteria   *Criteria `json:",omitempty"`
	OrderBy    string    `json:",omitempty"`
	Limit      int       `json:",omitempty"`
	Offset     int       `json:",omitempty"`
	CaseFormat string    `json:",omitempty"`
	OmitEmpty  bool      `json:",omitempty"`
	// contains filtered or unexported fields
}

Selector represent a view selector for projection and selection

func (*Selector) Apply

func (s *Selector) Apply(bindings map[string]interface{})

Apply applies selector values

func (Selector) Clone

func (s Selector) Clone() *Selector

Clone clones this selector

func (*Selector) IsSelected

func (s *Selector) IsSelected(columns []string) bool

IsSelected returns true if supplied column matched selector.columns or selector has no specified columns.

type Value

type Value struct {
	*gtly.Object
	Prev *gtly.Object
}

Value represents visitor value

func NewValue

func NewValue(object, prev *gtly.Object) *Value

NewValue creates a value

type View

type View struct {
	Connector  string
	Name       string
	Alias      string        `json:",omitempty"`
	Table      string        `json:",omitempty"`
	From       *From         `json:",omitempty"`
	Criteria   *Criteria     `json:",omitempty"`
	Selector   Selector      `json:",omitempty"`
	Joins      []*Join       `json:",omitempty"`
	Refs       []*Reference  `json:",omitempty"`
	Params     []interface{} `json:",omitempty"`
	CaseFormat string        `json:",omitempty"`
	HideRefIDs bool          `json:",omitempty"`

	PrimaryKey []string     `json:",omitempty"`
	Mutable    *bool        `json:",omitempty"`
	Columns    []*Column    `json:",omitempty"`
	Parameters []*Parameter `json:",omitempty"`
	Cache      *Cache       `json:",omitempty"`
	OnRead     *Visitor     `json:",omitempty"`
	OnPath     *Visitor     `json:",omitempty"`
	// contains filtered or unexported fields
}

View represents a view view

func (*View) AddJoin

func (v *View) AddJoin(join *Join)

AddJoin add join

func (View) BuildSQL

func (v View) BuildSQL(selector *Selector, bindings map[string]interface{}) (string, []interface{}, error)

BuildSQL build view view FromFragments

func (*View) Cacher

func (v *View) Cacher() cache2.Service

Cacher returns a cache service

func (*View) Clone

func (v *View) Clone() *View

Clone creates a view clone

func (*View) Init

func (v *View) Init(setPrefix bool) error

Init initializes view

func (*View) IsMutable

func (v *View) IsMutable() bool

IsMutable returns true if mutable

func (*View) LoadSQL

func (v *View) LoadSQL(ctx context.Context, fs afs.Service, parentURL string) error

LoadSQL loads fromSQL

func (*View) MergeFrom

func (v *View) MergeFrom(tmpl *View)

MergeFrom merges from template view

func (View) Validate

func (v View) Validate() error

Validate checks if view is valid

type Visit

type Visit func(ctx *Context, value *Value) (bool, error)

Visit represent an object visitor

type Visitor

type Visitor struct {
	Visitor string
	// contains filtered or unexported fields
}

Visitor represents a visitor

func (*Visitor) Init

func (v *Visitor) Init() error

Init initialises visitors

func (*Visitor) Visit

func (v *Visitor) Visit(ctx *Context, value *Value) (bool, error)

Visit visit an object

type Visitors

type Visitors interface {
	//Register registers visitor
	Register(name string, visitor Visit)
	//Get returns visitor
	Get(name string) (Visit, error)
	//Remove removes visitor
	Remove(name string)
}

Registry represents hook visitors

func VisitorRegistry

func VisitorRegistry() Visitors

Data returns visitor visitors singleton

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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