qcode

package
v0.15.57 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CTConnect uint8 = 1 << iota
	CTDisconnect
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AggregrateOp

type AggregrateOp int8
const (
	AgCount AggregrateOp = iota + 1
	AgSum
	AgAvg
	AgMax
	AgMin
)

func (AggregrateOp) String

func (i AggregrateOp) String() string

type Arg

type Arg struct {
	Val string
}

type Column

type Column struct {
	Col       sdata.DBColumn
	FieldName string
	Base      bool
}

type Compiler

type Compiler struct {
	// contains filtered or unexported fields
}

func NewCompiler

func NewCompiler(s *sdata.DBSchema, c Config) (*Compiler, error)

func (*Compiler) AddRole

func (co *Compiler) AddRole(role, table string, trc TRConfig) error

func (*Compiler) Compile

func (co *Compiler) Compile(query []byte, vars Variables, role string) (*QCode, error)

type Config

type Config struct {
	Vars            map[string]string
	FragmentFetcher func(name string) (string, error)
	DefaultBlock    bool
	DefaultLimit    int
	// contains filtered or unexported fields
}

type DeleteConfig

type DeleteConfig struct {
	Filters []string
	Columns []string
	Block   bool
}

type Exp

type Exp struct {
	Op       ExpOp
	Table    string
	Rels     []sdata.DBRel
	Col      sdata.DBColumn
	Type     ValType
	Val      string
	ListType ValType
	ListVal  []string
	Children []*Exp
	// contains filtered or unexported fields
}

func NewFilter

func NewFilter() *Exp

func (*Exp) Free

func (ex *Exp) Free()

func (*Exp) IsFromQuery

func (ex *Exp) IsFromQuery() bool

func (*Exp) Reset

func (ex *Exp) Reset()

type ExpOp

type ExpOp int8
const (
	OpNop ExpOp = iota
	OpAnd
	OpOr
	OpNot
	OpEquals
	OpNotEquals
	OpGreaterOrEquals
	OpLesserOrEquals
	OpGreaterThan
	OpLesserThan
	OpIn
	OpNotIn
	OpLike
	OpNotLike
	OpILike
	OpNotILike
	OpSimilar
	OpNotSimilar
	OpRegex
	OpNotRegex
	OpIRegex
	OpNotIRegex
	OpContains
	OpContainedIn
	OpHasKey
	OpHasKeyAny
	OpHasKeyAll
	OpIsNull
	OpTsQuery
	OpFalse
	OpNotDistinct
	OpDistinct
	OpEqualsTrue
	OpNotEqualsTrue
)

func (ExpOp) String

func (t ExpOp) String() string

type Filter

type Filter struct {
	*Exp
}

type Function

type Function struct {
	Name      string
	Col       sdata.DBColumn
	FieldName string
	// contains filtered or unexported fields
}

type InsertConfig

type InsertConfig struct {
	Columns []string
	Presets map[string]string
	Block   bool
}

type MColumn

type MColumn struct {
	Col       sdata.DBColumn
	FieldName string
	Value     string
}

type MRColumn

type MRColumn struct {
	Col   sdata.DBColumn
	VCol  sdata.DBColumn
	CType uint8
}

type MTable

type MTable struct {
	Ti    sdata.DBTableInfo
	CType uint8
}

type MType

type MType uint8
const (
	MTInsert MType = iota + 1
	MTUpdate
	MTUpsert
	MTDelete
	MTConnect
	MTDisconnect
	MTNone
	MTKeyword
)

func (MType) String

func (i MType) String() string

type Mutate

type Mutate struct {
	ID    int32
	Type  MType
	CType uint8
	Key   string
	Path  []string
	Val   json.RawMessage
	Data  map[string]json.RawMessage
	Array bool

	Cols   []MColumn
	RCols  []MRColumn
	Tables []MTable
	Ti     sdata.DBTableInfo
	RelCP  sdata.DBRel
	RelPC  sdata.DBRel
	Items  []Mutate
	Multi  bool
	MID    int32
	// contains filtered or unexported fields
}

type Order

type Order int8
const (
	OrderAsc Order = iota + 1
	OrderDesc
	OrderAscNullsFirst
	OrderAscNullsLast
	OrderDescNullsFirst
	OrderDescNullsLast
)

type OrderBy

type OrderBy struct {
	Col   sdata.DBColumn
	Order Order
}

type Paging

type Paging struct {
	Type      PagingType
	LimitVar  string
	Limit     int32
	OffsetVar string
	Offset    int32
	Cursor    bool
	NoLimit   bool
}

type PagingType

type PagingType int8
const (
	PTOffset PagingType = iota
	PTForward
	PTBackward
)

func (PagingType) String

func (i PagingType) String() string

type QCode

type QCode struct {
	Type      QType
	SType     QType
	ActionVar string
	Selects   []Select
	Vars      Variables
	Roots     []int32

	Mutates []Mutate
	MCounts map[string]int32
	Schema  *sdata.DBSchema
	Remotes int32
	// contains filtered or unexported fields
}

type QType

type QType int8
const (
	QTUnknown QType = iota
	QTQuery
	QTSubscription
	QTMutation
	QTInsert
	QTUpdate
	QTDelete
	QTUpsert
)

func GetQType

func GetQType(gql string) (QType, string)

func (QType) String

func (i QType) String() string

type QueryConfig

type QueryConfig struct {
	Limit            int
	Filters          []string
	Columns          []string
	DisableFunctions bool
	Block            bool
}

type SelType

type SelType int8
const (
	SelTypeNone SelType = iota
	SelTypeUnion
	SelTypeMember
)

func (SelType) String

func (i SelType) String() string

type Select

type Select struct {
	ID         int32
	ParentID   int32
	UParentID  int32
	Type       SelType
	Singular   bool
	Typename   bool
	Table      string
	FieldName  string
	Cols       []Column
	ColMap     map[string]int
	ArgMap     map[string]Arg
	Funcs      []Function
	Where      Filter
	OrderBy    []OrderBy
	GroupCols  bool
	DistinctOn []sdata.DBColumn
	Paging     Paging
	Children   []int32
	SkipRender SkipType
	Ti         sdata.DBTableInfo
	Rel        sdata.DBRel
	// contains filtered or unexported fields
}

type SkipType

type SkipType int8
const (
	SkipTypeNone SkipType = iota
	SkipTypeUserNeeded
	SkipTypeRemote
)

func (SkipType) String

func (i SkipType) String() string

type TRConfig

type TRConfig struct {
	Query  QueryConfig
	Insert InsertConfig
	Update UpdateConfig
	Upsert UpsertConfig
	Delete DeleteConfig
}

type UpdateConfig

type UpdateConfig struct {
	Filters []string
	Columns []string
	Presets map[string]string
	Block   bool
}

type UpsertConfig

type UpsertConfig struct {
	Filters []string
	Columns []string
	Presets map[string]string
	Block   bool
}

type ValType

type ValType int8
const (
	ValStr ValType = iota + 1
	ValNum
	ValBool
	ValList
	ValVar
	ValNone
	ValRef
)

func (ValType) String

func (i ValType) String() string

type Variables

type Variables map[string]json.RawMessage

Jump to

Keyboard shortcuts

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