xpr

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AliasNode added in v0.1.3

type AliasNode struct {
	Alias string
	Field interface{}
}

AliasNode node used to specify a field or column using an table alias reference

func AliasColumn added in v0.1.3

func AliasColumn(alias string, columnname string) *AliasNode

AliasColumn specifies a column of a table using a table alias

func AliasField added in v0.1.3

func AliasField(alias string, model *models.EntityModel, fieldname string) *AliasNode

AliasField specify a field of an entity using a table alias

type BinaryNode

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

BinaryNode - node which combines two operands using an operator

func Add

func Add(lhs interface{}, rhs interface{}) *BinaryNode

Add creates a binary node used to add two values

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func And

func And(lhs interface{}, rhs interface{}) *BinaryNode

And creates a binary node for an AND operation

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Assign

func Assign(lhs interface{}, rhs interface{}) *BinaryNode

Assign creates a binary node for an Assign operation

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Binary

func Binary(lhs interface{}, operator BinaryOperation, rhs interface{}) *BinaryNode

Binary creates a new binary node to be used in an expression tree

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Div

func Div(lhs interface{}, rhs interface{}) *BinaryNode

Div creates a binary node used to divide a value by another

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Equals

func Equals(lhs interface{}, rhs interface{}) *BinaryNode

Equals creates a binary node for an Equals operation

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func EqualsNot

func EqualsNot(lhs interface{}, rhs interface{}) *BinaryNode

EqualsNot creates a binary node for an Not Equal operation

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Geq

func Geq(lhs interface{}, rhs interface{}) *BinaryNode

Geq creates a binary node used to compare whether a value is greater or equal to another

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Grt

func Grt(lhs interface{}, rhs interface{}) *BinaryNode

Grt creates a binary node used to compare whether a value is greater than another

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Leq

func Leq(lhs interface{}, rhs interface{}) *BinaryNode

Leq creates a binary node used to compare whether a value is less or equal to another

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Les

func Les(lhs interface{}, rhs interface{}) *BinaryNode

Les creates a binary node used to compare whether a value is less than another

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Like added in v0.2.0

func Like(lhs interface{}, rhs interface{}) *BinaryNode

Like - creates a binary node for a Like operation

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Mul

func Mul(lhs interface{}, rhs interface{}) *BinaryNode

Mul creates a binary node used to multiply a value with another

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Or

func Or(lhs interface{}, rhs interface{}) *BinaryNode

Or creates a binary node for an OR operation

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func Sub

func Sub(lhs interface{}, rhs interface{}) *BinaryNode

Sub creates a binary node used to subtract a value from another

**Parameters**

  • lhs: left hand side operand
  • rhs: right hand side operand

**Returns**

  • *BinaryNode: node to use in expression trees

func (*BinaryNode) Lhs

func (node *BinaryNode) Lhs() interface{}

func (*BinaryNode) Operator

func (node *BinaryNode) Operator() BinaryOperation

func (*BinaryNode) Rhs

func (node *BinaryNode) Rhs() interface{}

type BinaryOperation

type BinaryOperation int
const (
	BinaryAnd BinaryOperation = iota
	BinaryOr
	BinaryEquals
	BinaryNotEqual
	BinaryGreater
	BinaryGreaterEqual
	BinaryLess
	BinaryLessEqual
	BinaryAdd
	BinarySub
	BinaryDiv
	BinaryMul
	BinaryMod
	BinaryShl
	BinaryShr
	BinaryBitAnd
	BinaryBitOr
	BinaryBitXor
	BinaryAssign
	BinaryLike
)

type ColumnNode added in v0.1.3

type ColumnNode struct {
	Name string
}

ColumnNode node used to specify a column

func Column added in v0.2.6

func Column(name string) *ColumnNode

Column - creates a new node representing a column

type FieldNode

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

FieldNode - node representing a field in an entity type

func Field

func Field(model *models.EntityModel, name string) *FieldNode

Field - creates a new node representing an entity field

func (*FieldNode) Model

func (node *FieldNode) Model() *models.EntityModel

Model model in which field is stored

func (*FieldNode) Name

func (node *FieldNode) Name() string

Name name of field

type FunctionNode

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

FunctionNode node in an expression tree representing a database function

func Average added in v0.1.5

func Average(field interface{}) *FunctionNode

Average computes the average of a series of values

func Coalesce added in v0.2.2

func Coalesce(collection ...interface{}) *FunctionNode

Coalesce - returns first value from collection which is not null or null

if all values are null

func Count

func Count() *FunctionNode

Count used to count number of rows returned

func Max added in v0.1.5

func Max(param interface{}) *FunctionNode

Max get maximum value of a series of values

**Parameters**

  • param: expression which specifies values of which to get maximum

**Returns**

  • *FunctionNode: node to use in expression

func Min added in v0.1.5

func Min(param interface{}) *FunctionNode

Min get minimum value of a series of values

**Parameters**

  • param: expression which specifies values of which to get minimum

**Returns**

  • *FunctionNode: node to use in expression

func (*FunctionNode) Function

func (node *FunctionNode) Function() FunctionType

Function function type

func (*FunctionNode) Parameters

func (node *FunctionNode) Parameters() []interface{}

Parameters parameters for function to call

type FunctionType

type FunctionType int

FunctionType type of database function

const (
	// FunctionCount counts rows in a result set
	FunctionCount FunctionType = iota

	// FunctionRandom get a random number
	FunctionRandom

	// FunctionAverage average of a set of values
	FunctionAverage

	// FunctionSum of a set of values
	FunctionSum

	// FunctionMax maximum of a set of values
	FunctionMax

	// FunctionMin minimum of a set of values
	FunctionMin

	// FunctionCoalesce returns first value from list which is not null, null if all values are null
	FunctionCoalesce
)

type InCollectionNode added in v0.1.2

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

InCollectionNode predicate node which expects an item to be part of a collection

in sql this translates to an 'item IN (collection)' statement

func In added in v0.1.2

func In(item interface{}, collection ...interface{}) *InCollectionNode

In checks for existence of an item in a collection

func (*InCollectionNode) Collection added in v0.1.2

func (node *InCollectionNode) Collection() []interface{}

Collection collection of items to be checked

func (*InCollectionNode) Item added in v0.1.2

func (node *InCollectionNode) Item() interface{}

Item item to check for in the collection

type ParameterNode

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

ParameterNode node representing a parameter in a statement

func NamedParameter added in v0.1.1

func NamedParameter(name string) *ParameterNode

NamedParameter - creates a new node representing a named statement parameter

func Parameter

func Parameter() *ParameterNode

Parameter - creates a new node representing a positional statement parameter

func (*ParameterNode) Name added in v0.1.1

func (node *ParameterNode) Name() string

Name name or index of parameter

type StatementNode added in v0.1.5

type StatementNode struct {
	Statement interfaces.IPreparedOperation
}

StatementNode node used to include a statement in an expression

func Statement added in v0.1.5

func Statement(statement interfaces.IPreparedOperation) *StatementNode

Statement includes a sub statement in an expression

type TableNode added in v0.2.0

type TableNode struct {
	Name string // name of table
}

TableNode - node specifying a table in an expression

func Table added in v0.2.0

func Table(name string) *TableNode

Table - creates a node which specifies a table

type UnaryNode

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

UnaryNode - unary operator to a node

func (*UnaryNode) Operator

func (node *UnaryNode) Operator() UnaryOperation

Operator - type of unary operation

func (*UnaryNode) Value

func (node *UnaryNode) Value() interface{}

Value - operation value

type UnaryOperation

type UnaryOperation int

UnaryOperation - type of unary expression node

const (
	// Not - logical Not
	Not UnaryOperation = iota

	// Negate - negate connected node
	Negate

	// Complement - compute complement of node
	Complement
)

Jump to

Keyboard shortcuts

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