Documentation ¶
Index ¶
- Constants
- func ColumnNodeDbName(n *ColumnNode) string
- func ExpandNode(n NodeI)
- func LogNode(n NodeI, level int)
- func ManyManyNodeDbColumn(n *ManyManyNode) string
- func ManyManyNodeDbTable(n *ManyManyNode) string
- func ManyManyNodeIsArray(n *ManyManyNode) bool
- func ManyManyNodeIsTypeTable(n *ManyManyNode) bool
- func ManyManyNodeRefColumn(n *ManyManyNode) string
- func ManyManyNodeRefTable(n *ManyManyNode) string
- func NodeGoName(n NodeI) string
- func NodeIsConditioner(n NodeI) bool
- func NodeIsExpanded(n NodeI) bool
- func NodeIsExpander(n NodeI) bool
- func NodeSetCondition(n NodeI, condition NodeI)
- func NodeSorterSortDesc(n NodeSorter) bool
- func NodeTableName(n NodeI) string
- func OperationIsAggregate(n *OperationNode) bool
- func OperationNodeDistinct(n *OperationNode) bool
- func OperationNodeFunction(n *OperationNode) string
- func OperationSortDescending(n *OperationNode) bool
- func ReferenceNodeDbColumnName(n *ReferenceNode) string
- func ReferenceNodeRefColumn(n *ReferenceNode) string
- func ReferenceNodeRefTable(n *ReferenceNode) string
- func ReverseReferenceNodeDbColumnName(n *ReverseReferenceNode) string
- func ReverseReferenceNodeIsArray(n *ReverseReferenceNode) bool
- func ReverseReferenceNodeRefColumn(n *ReverseReferenceNode) string
- func ReverseReferenceNodeRefTable(n *ReverseReferenceNode) string
- func SetParentNode(child NodeI, parent NodeI)
- func ValueNodeGetValue(n *ValueNode) interface{}
- type AliasNode
- type AliasNodeI
- type AliasValue
- type ClauseI
- type ColumnNode
- type ExpandClause
- type Expander
- type FieldType
- type GoColumnType
- type LimitClause
- type ManyManyNode
- type Node
- type NodeI
- func ChildNodes(n nodeLinkI) []NodeI
- func ContainedNodes(n NodeI) (nodes []NodeI)
- func NewValueNode(i interface{}) NodeI
- func NodeCondition(n NodeI) NodeI
- func OperationNodeOperands(n *OperationNode) []NodeI
- func ParentNode(n NodeI) NodeI
- func RelatedColumnNode(n NodeI) NodeI
- func RootNode(n nodeLinkI) NodeI
- func Value(i interface{}) NodeI
- type NodeSorter
- type NodeType
- type OperationNode
- type Operator
- type OrderByClause
- type QueryBuilderI
- type ReferenceNode
- type ReverseReferenceNode
- type SelectClause
- type SubqueryNode
- type TableNode
- type TableNodeI
- type ValueNode
Constants ¶
const ( ColTypeUnknown GoColumnType = "" ColTypeBytes = "[]byte" ColTypeString = "string" ColTypeInteger = "int" ColTypeUnsigned = "uint" ColTypeInteger64 = "int64" ColTypeUnsigned64 = "uint64" ColTypeDateTime = "datetime.DateTime" ColTypeFloat = "float32" // always internally represent with max bits ColTypeDouble = "float64" // always internally represent with max bits ColTypeBool = "bool" )
const ( // Standard logical operators OpEqual Operator = "=" OpNotEqual Operator = "<>" OpAnd = "AND" OpOr = "OR" OpXor = "XOR" OpGreater = ">" OpGreaterEqual = ">=" OpLess = "<" OpLessEqual = "<=" // Unary logical OpNot = "NOT" OpAll = "1=1" OpNone = "1=0" // Math operators OpAdd = "+" OpSubtract = "-" OpMultiply = "*" OpDivide = "/" OpModulo = "%" // Unary math OpNegate = " -" // Bit operators OpBitAnd = "&" OpBitOr = "|" OpBitXor = "^" OpShiftLeft = "<<" OpShiftRight = ">>" // Unary bit OpBitInvert = "~" // Function operator // The function name is followed by the operators in parenthesis OpFunc = "func" // SQL functions that act like operators in that the operator is put in between the operands OpLike = "LIKE" OpIn = "IN" OpNotIn = "NOT IN" // Special NULL tests OpNull = "NULL" OpNotNull = "NOT NULL" )
const AliasResults = "aliases_"
The special item to use for named aliases in the result set
Variables ¶
This section is empty.
Functions ¶
func ColumnNodeDbName ¶
func ColumnNodeDbName(n *ColumnNode) string
func ExpandNode ¶
func ExpandNode(n NodeI)
func ManyManyNodeDbColumn ¶
func ManyManyNodeDbColumn(n *ManyManyNode) string
func ManyManyNodeDbTable ¶
func ManyManyNodeDbTable(n *ManyManyNode) string
func ManyManyNodeIsArray ¶
func ManyManyNodeIsArray(n *ManyManyNode) bool
func ManyManyNodeIsTypeTable ¶
func ManyManyNodeIsTypeTable(n *ManyManyNode) bool
func ManyManyNodeRefColumn ¶
func ManyManyNodeRefColumn(n *ManyManyNode) string
func ManyManyNodeRefTable ¶
func ManyManyNodeRefTable(n *ManyManyNode) string
func NodeGoName ¶
func NodeIsConditioner ¶
func NodeIsExpanded ¶
func NodeIsExpander ¶
func NodeSetCondition ¶
func NodeSorterSortDesc ¶
func NodeSorterSortDesc(n NodeSorter) bool
func NodeTableName ¶
func OperationIsAggregate ¶
func OperationIsAggregate(n *OperationNode) bool
func OperationNodeDistinct ¶
func OperationNodeDistinct(n *OperationNode) bool
func OperationNodeFunction ¶
func OperationNodeFunction(n *OperationNode) string
func OperationSortDescending ¶
func OperationSortDescending(n *OperationNode) bool
func ReferenceNodeDbColumnName ¶
func ReferenceNodeDbColumnName(n *ReferenceNode) string
func ReferenceNodeRefColumn ¶
func ReferenceNodeRefColumn(n *ReferenceNode) string
func ReferenceNodeRefTable ¶
func ReferenceNodeRefTable(n *ReferenceNode) string
func ReverseReferenceNodeDbColumnName ¶
func ReverseReferenceNodeDbColumnName(n *ReverseReferenceNode) string
func ReverseReferenceNodeIsArray ¶
func ReverseReferenceNodeIsArray(n *ReverseReferenceNode) bool
func ReverseReferenceNodeRefColumn ¶
func ReverseReferenceNodeRefColumn(n *ReverseReferenceNode) string
func ReverseReferenceNodeRefTable ¶
func ReverseReferenceNodeRefTable(n *ReverseReferenceNode) string
func SetParentNode ¶
Used by the query builder to build a join tree, and by the codegenerator to initialize nodes
func ValueNodeGetValue ¶
func ValueNodeGetValue(n *ValueNode) interface{}
Types ¶
type AliasNodeI ¶
type AliasNodeI interface { NodeI }
type AliasValue ¶
type AliasValue struct {
// contains filtered or unexported fields
}
func NewAliasValue ¶
func NewAliasValue(a interface{}) AliasValue
func (AliasValue) Bool ¶
func (a AliasValue) Bool() bool
func (AliasValue) DateTime ¶
func (a AliasValue) DateTime() datetime.DateTime
func (AliasValue) Float ¶
func (a AliasValue) Float() float64
func (AliasValue) Int ¶
func (a AliasValue) Int() int
func (AliasValue) IsNil ¶
func (a AliasValue) IsNil() bool
func (AliasValue) IsNull ¶
func (a AliasValue) IsNull() bool
func (AliasValue) String ¶
func (a AliasValue) String() string
type ClauseI ¶
type ClauseI interface {
AddToBuilder(b QueryBuilderI)
}
type ColumnNode ¶
type ColumnNode struct { Node // contains filtered or unexported fields }
A Column represents a table or field in a database structure, and is the leaf of a node tree or chain.
func NewColumnNode ¶
func NewColumnNode(dbKey string, dbTable string, dbName string, goName string, goType GoColumnType) *ColumnNode
func (*ColumnNode) Ascending ¶
func (n *ColumnNode) Ascending() NodeI
func (*ColumnNode) Descending ¶
func (n *ColumnNode) Descending() NodeI
func (*ColumnNode) Equals ¶
func (n *ColumnNode) Equals(n2 NodeI) bool
func (*ColumnNode) SetValue ¶
func (n *ColumnNode) SetValue(v interface{}) error
type ExpandClause ¶
type ExpandClause struct {
// contains filtered or unexported fields
}
func Expand ¶
func Expand(node NodeI, condition NodeI) *ExpandClause
func (*ExpandClause) AddToBuilder ¶
func (c *ExpandClause) AddToBuilder(b QueryBuilderI)
type GoColumnType ¶
type GoColumnType string
func ColumnNodeGoType ¶
func ColumnNodeGoType(n *ColumnNode) GoColumnType
func (GoColumnType) DefaultValue ¶
func (g GoColumnType) DefaultValue() string
func (GoColumnType) String ¶
func (g GoColumnType) String() string
type LimitClause ¶
type LimitClause struct {
// contains filtered or unexported fields
}
func Limit ¶
func Limit(maxRowCount int, offset int) *LimitClause
func (*LimitClause) AddToBuilder ¶
func (c *LimitClause) AddToBuilder(b QueryBuilderI)
type ManyManyNode ¶
type ManyManyNode struct { Node // contains filtered or unexported fields }
ManyManyNode creates an association node. Some of the columns have overloaded meanings depending on SQL or NoSQL mode.
func NewManyManyNode ¶
func (*ManyManyNode) Equals ¶
func (n *ManyManyNode) Equals(n2 NodeI) bool
func (*ManyManyNode) Expand ¶
func (n *ManyManyNode) Expand()
Expand tells this node to create multiple objects for each joined item, rather than to create an array of joined items
type NodeI ¶
type NodeI interface { Equals(NodeI) bool SetAlias(string) GetAlias() string // contains filtered or unexported methods }
func ChildNodes ¶
func ChildNodes(n nodeLinkI) []NodeI
func ContainedNodes ¶
func NewValueNode ¶
func NewValueNode(i interface{}) NodeI
func NodeCondition ¶
func OperationNodeOperands ¶
func OperationNodeOperands(n *OperationNode) []NodeI
func ParentNode ¶
func RelatedColumnNode ¶
type NodeSorter ¶
type OperationNode ¶
type OperationNode struct { Node // contains filtered or unexported fields }
An operation is a general purpose structure that specs an operation on a node or group of nodes The operation could be arithmetic, boolean, or a function.
func NewCountNode ¶
func NewCountNode(operands ...NodeI) *OperationNode
NewCountNode creates a Count function node. If no operands are given, it will use * as the parameter to the function which means it will count nulls. To NOT count nulls, at least one table name needs to be specified.
func NewFunctionNode ¶
func NewFunctionNode(functionName string, operands ...interface{}) *OperationNode
func NewOperationNode ¶
func NewOperationNode(op Operator, operands ...interface{}) *OperationNode
func (*OperationNode) Ascending ¶
func (n *OperationNode) Ascending() *OperationNode
func (*OperationNode) Descending ¶
func (n *OperationNode) Descending() *OperationNode
func (*OperationNode) Distinct ¶
func (n *OperationNode) Distinct() *OperationNode
func (*OperationNode) Equals ¶
func (n *OperationNode) Equals(n2 NodeI) bool
type Operator ¶
type Operator string
func OperationNodeOperator ¶
func OperationNodeOperator(n *OperationNode) Operator
type OrderByClause ¶
type OrderByClause struct {
// contains filtered or unexported fields
}
func OrderBy ¶
func OrderBy(nodes ...NodeI) *OrderByClause
func (*OrderByClause) AddToBuilder ¶
func (c *OrderByClause) AddToBuilder(b QueryBuilderI)
type QueryBuilderI ¶
type QueryBuilderI interface { Join(n NodeI, condition NodeI) QueryBuilderI Expand(n NodeI) QueryBuilderI Condition(c NodeI) QueryBuilderI Having(c NodeI) QueryBuilderI OrderBy(nodes ...NodeI) QueryBuilderI GroupBy(nodes ...NodeI) QueryBuilderI Limit(maxRowCount int, offset int) QueryBuilderI Select(nodes ...NodeI) QueryBuilderI Distinct() QueryBuilderI Alias(name string, n NodeI) QueryBuilderI Load(ctx context.Context) []map[string]interface{} Delete(ctx context.Context) Count(ctx context.Context, distinct bool, nodes ...NodeI) uint Subquery() *SubqueryNode }
The query builder is the primary aid in creating cross-platform, portable queries to the database(s)
func SubqueryBuilder ¶
func SubqueryBuilder(n *SubqueryNode) QueryBuilderI
type ReferenceNode ¶
type ReferenceNode struct { Node // contains filtered or unexported fields }
A ReferenceNode is a forward-pointing foreignKey relationship, and can define a one-to-one or one-to-many relationship, with this side always being the one side. It also sets up a many-to-one relationship, if it is not unique, when viewed from the other side of the relationship.
func NewReferenceNode ¶
func NewReferenceNode( dbKey string, dbTableName string, dbColumnName string, goColumnName string, goName string, refTableName string, refColumn string, isType bool, ) *ReferenceNode
NewReferenceNode creates a forward reference node.
func (*ReferenceNode) Equals ¶
func (n *ReferenceNode) Equals(n2 NodeI) bool
type ReverseReferenceNode ¶
type ReverseReferenceNode struct { Node // contains filtered or unexported fields }
ReverseReferenceNode creates a reverse reference node representing a one to many relationship. This is the many side of that relationship.
func NewReverseReferenceNode ¶
func (*ReverseReferenceNode) Equals ¶
func (n *ReverseReferenceNode) Equals(n2 NodeI) bool
func (*ReverseReferenceNode) Expand ¶
func (n *ReverseReferenceNode) Expand()
func (*ReverseReferenceNode) IsArray ¶
func (n *ReverseReferenceNode) IsArray() bool
type SelectClause ¶
type SelectClause struct {
// contains filtered or unexported fields
}
func Select ¶
func Select(nodes ...NodeI) *SelectClause
func (*SelectClause) AddToBuilder ¶
func (c *SelectClause) AddToBuilder(b QueryBuilderI)
type SubqueryNode ¶
type SubqueryNode struct { Node // contains filtered or unexported fields }
func NewSubqueryNode ¶
func NewSubqueryNode(b QueryBuilderI) *SubqueryNode
func (*SubqueryNode) Equals ¶
func (n *SubqueryNode) Equals(n2 NodeI) bool
type TableNode ¶
type TableNode struct { Node // contains filtered or unexported fields }
func NewTableNode ¶
NewTableNode creates a table node, which is always the starting node in a node chain
type TableNodeI ¶
type TableNodeI interface { NodeI SelectNodes_() []*ColumnNode PrimaryKeyNode_() *ColumnNode EmbeddedNode_() NodeI }