cypher

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

View Source
const (
	CountFunction              = "count"
	DateFunction               = "date"
	TimeFunction               = "time"
	LocalTimeFunction          = "localtime"
	DateTimeFunction           = "datetime"
	LocalDateTimeFunction      = "localdatetime"
	DurationFunction           = "duration"
	IdentityFunction           = "id"
	ToLowerFunction            = "tolower"
	ToUpperFunction            = "toupper"
	NodeLabelsFunction         = "labels"
	EdgeTypeFunction           = "type"
	StringSplitToArrayFunction = "split"
	ToStringFunction           = "tostring"
	ToIntegerFunction          = "toint"
	ListSizeFunction           = "size"
	CoalesceFunction           = "coalesce"
	CollectFunction            = "collect"
	SumFunction                = "sum"
	AvgFunction                = "avg"
	MinFunction                = "min"
	MaxFunction                = "max"

	// ITTC - Instant Type; Temporal Component (https://neo4j.com/docs/cypher-manual/current/functions/temporal/)
	ITTCYear              = "year"
	ITTCMonth             = "month"
	ITTCDay               = "day"
	ITTCHour              = "hour"
	ITTCMinute            = "minute"
	ITTCSecond            = "second"
	ITTCMillisecond       = "millisecond"
	ITTCMicrosecond       = "microsecond"
	ITTCNanosecond        = "nanosecond"
	ITTCTimeZone          = "timezone"
	ITTCEpochSeconds      = "epochseconds"
	ITTCEpochMilliseconds = "epochmillis"
)
View Source
const (
	TokenLiteralAsterisk = "*"

	QuantifierTypeAll     = QuantifierType("all")
	QuantifierTypeAny     = QuantifierType("any")
	QuantifierTypeNone    = QuantifierType("none")
	QuantifierTypeSingle  = QuantifierType("single")
	QuantifierTypeInvalid = QuantifierType("")

	SortAscending  = SortOrder("asc")
	SortDescending = SortOrder("desc")

	OperatorAssignment         = AssignmentOperator("=")
	OperatorAdditionAssignment = AssignmentOperator("+=")
	OperatorLabelAssignment    = AssignmentOperator("")

	OperatorAdd                  = Operator("+")
	OperatorSubtract             = Operator("-")
	OperatorMultiply             = Operator("*")
	OperatorDivide               = Operator("/")
	OperatorModulo               = Operator("%")
	OperatorPowerOf              = Operator("^")
	OperatorEquals               = Operator("=")
	OperatorRegexMatch           = Operator("=~")
	OperatorNotEquals            = Operator("<>")
	OperatorGreaterThan          = Operator(">")
	OperatorGreaterThanOrEqualTo = Operator(">=")
	OperatorLessThan             = Operator("<")
	OperatorLessThanOrEqualTo    = Operator("<=")
	OperatorStartsWith           = Operator("starts with")
	OperatorEndsWith             = Operator("ends with")
	OperatorContains             = Operator("contains")
	OperatorIn                   = Operator("in")
	OperatorIs                   = Operator("is")
	OperatorIsNot                = Operator("is not")
	OperatorNot                  = Operator("not")
	OperatorAnd                  = Operator("and")
	OperatorOr                   = Operator("or")
	OperatorInvalid              = Operator("")
)

Variables

View Source
var (
	GreedyRangeQuantifier = NewRangeQuantifier("*")
)

Functions

func Copy

func Copy[T any](value T, extensions ...CopyExtension[T]) T

func NewRegularQueryWithSingleQuery added in v0.1.4

func NewRegularQueryWithSingleQuery() (*RegularQuery, *SinglePartQuery)

func WithErrors

func WithErrors[T Fallible](fallible T, errs ...error) T

Types

type ArithmeticExpression

type ArithmeticExpression struct {
	Left     Expression
	Partials []*PartialArithmeticExpression
}

func NewArithmeticExpression

func NewArithmeticExpression() *ArithmeticExpression

func (*ArithmeticExpression) AddArithmeticExpressionPart

func (s *ArithmeticExpression) AddArithmeticExpressionPart(part *PartialArithmeticExpression)

type AssignmentOperator

type AssignmentOperator string

func (AssignmentOperator) String

func (s AssignmentOperator) String() string

type Comparison

type Comparison struct {
	Left     Expression
	Partials []*PartialComparison
}

func NewComparison

func NewComparison(left Expression, operator Operator, right Expression) *Comparison

func (*Comparison) AddPartialComparison

func (s *Comparison) AddPartialComparison(partial *PartialComparison)

func (*Comparison) FirstPartial

func (s *Comparison) FirstPartial() *PartialComparison

func (*Comparison) LastPartial

func (s *Comparison) LastPartial() *PartialComparison

func (*Comparison) NewPartialComparison added in v0.1.4

func (s *Comparison) NewPartialComparison(operator Operator, rightOperand Expression) *PartialComparison

type Conjunction

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

func NewConjunction

func NewConjunction(expressions ...Expression) *Conjunction

func (*Conjunction) Add

func (s *Conjunction) Add(expression Expression)

func (*Conjunction) AddSlice

func (s *Conjunction) AddSlice(expressions []Expression)

func (*Conjunction) Get

func (s *Conjunction) Get(index int) Expression

func (*Conjunction) GetAll

func (s *Conjunction) GetAll() []Expression

func (*Conjunction) IndexOf

func (s *Conjunction) IndexOf(expressionToFind Expression) int

func (*Conjunction) Len

func (s *Conjunction) Len() int

func (*Conjunction) Remove

func (s *Conjunction) Remove(expressionToRemove Expression) bool

func (*Conjunction) Replace

func (s *Conjunction) Replace(index int, expression Expression)

type CopyExtension

type CopyExtension[T any] func(value T) (T, bool)

type Create

type Create struct {
	Unique  bool
	Pattern []*PatternPart
	// contains filtered or unexported fields
}

func NewCreate

func NewCreate() *Create

func (*Create) AddError

func (s *Create) AddError(err error)

func (*Create) Errors

func (s *Create) Errors() []error

type Delete

type Delete struct {
	Detach      bool
	Expressions []Expression
}

func NewDelete

func NewDelete(detach bool, expressions []Expression) *Delete

func (*Delete) AddExpression added in v0.1.4

func (s *Delete) AddExpression(expression Expression)

type Disjunction

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

func NewDisjunction

func NewDisjunction(expressions ...Expression) *Disjunction

func (*Disjunction) Add

func (s *Disjunction) Add(expression Expression)

func (*Disjunction) AddSlice

func (s *Disjunction) AddSlice(expressions []Expression)

func (*Disjunction) Get

func (s *Disjunction) Get(index int) Expression

func (*Disjunction) GetAll

func (s *Disjunction) GetAll() []Expression

func (*Disjunction) IndexOf

func (s *Disjunction) IndexOf(expressionToFind Expression) int

func (*Disjunction) Len

func (s *Disjunction) Len() int

func (*Disjunction) Remove

func (s *Disjunction) Remove(expressionToRemove Expression) bool

func (*Disjunction) Replace

func (s *Disjunction) Replace(index int, expression Expression)

type ExclusiveDisjunction

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

func NewExclusiveDisjunction

func NewExclusiveDisjunction(expressions ...Expression) *ExclusiveDisjunction

func (*ExclusiveDisjunction) Add

func (s *ExclusiveDisjunction) Add(expression Expression)

func (*ExclusiveDisjunction) AddSlice

func (s *ExclusiveDisjunction) AddSlice(expressions []Expression)

func (*ExclusiveDisjunction) Get

func (s *ExclusiveDisjunction) Get(index int) Expression

func (*ExclusiveDisjunction) GetAll

func (s *ExclusiveDisjunction) GetAll() []Expression

func (*ExclusiveDisjunction) IndexOf

func (s *ExclusiveDisjunction) IndexOf(expressionToFind Expression) int

func (*ExclusiveDisjunction) Len

func (s *ExclusiveDisjunction) Len() int

func (*ExclusiveDisjunction) Remove

func (s *ExclusiveDisjunction) Remove(expressionToRemove Expression) bool

func (*ExclusiveDisjunction) Replace

func (s *ExclusiveDisjunction) Replace(index int, expression Expression)

type Expression

type Expression SyntaxNode

type ExpressionList

type ExpressionList interface {
	Add(expression Expression)
	AddSlice(expressions []Expression)
	Get(index int) Expression
	GetAll() []Expression
	Len() int
	IndexOf(expression Expression) int
	Remove(expression Expression) bool
	Replace(index int, expression Expression)
}

func NewExpressionList

func NewExpressionList() ExpressionList

func NewExpressionListFromSlice

func NewExpressionListFromSlice(slice []Expression) ExpressionList

type Fallible

type Fallible interface {
	AddError(err error)
	Errors() []error
}

type FilterExpression

type FilterExpression struct {
	Specifier *IDInCollection
	Where     *Where
}

func NewFilterExpression

func NewFilterExpression() *FilterExpression

type FunctionInvocation

type FunctionInvocation struct {
	Distinct  bool
	Namespace []string
	Name      string
	Arguments []Expression
	// contains filtered or unexported fields
}

func NewSimpleFunctionInvocation

func NewSimpleFunctionInvocation(name string, arguments ...Expression) *FunctionInvocation

func (*FunctionInvocation) AddArgument

func (s *FunctionInvocation) AddArgument(arg Expression)

func (*FunctionInvocation) AddError

func (s *FunctionInvocation) AddError(err error)

func (*FunctionInvocation) Errors

func (s *FunctionInvocation) Errors() []error

func (*FunctionInvocation) HasArguments

func (s *FunctionInvocation) HasArguments() bool

func (*FunctionInvocation) NumArguments

func (s *FunctionInvocation) NumArguments() int

type IDInCollection

type IDInCollection struct {
	Variable   *Variable
	Expression Expression
}

func NewIDInCollection

func NewIDInCollection() *IDInCollection

type KindMatcher

type KindMatcher struct {
	Reference Expression
	Kinds     graph.Kinds
}

func NewKindMatcher

func NewKindMatcher(reference Expression, kinds graph.Kinds) *KindMatcher

type Limit

type Limit struct {
	Value Expression
}

func NewLimit added in v0.1.4

func NewLimit(limit int) *Limit

type ListLiteral

type ListLiteral []Expression

func NewListLiteral

func NewListLiteral() *ListLiteral

func NewStringListLiteral added in v0.1.4

func NewStringListLiteral(values []string) *ListLiteral

func (*ListLiteral) Expressions

func (s *ListLiteral) Expressions() []Expression

func (*ListLiteral) Keys

func (s *ListLiteral) Keys() []any

type Literal

type Literal struct {
	Value any
	Null  bool
}

func NewLiteral

func NewLiteral(value any, null bool) *Literal

func NewStringLiteral

func NewStringLiteral(value string) *Literal

func (*Literal) Set

func (s *Literal) Set(value any) *Literal

func (*Literal) SetNull

func (s *Literal) SetNull() *Literal

type MapItem

type MapItem struct {
	Key   string
	Value Expression
}

type MapLiteral

type MapLiteral map[string]Expression

func NewMapLiteral

func NewMapLiteral() MapLiteral

func (MapLiteral) Items

func (s MapLiteral) Items() []*MapItem

func (MapLiteral) Keys

func (s MapLiteral) Keys() []any

type Match

type Match struct {
	Optional bool
	Pattern  []*PatternPart
	Where    *Where
}

func NewMatch

func NewMatch(optional bool) *Match

func (*Match) FirstRelationshipPattern

func (s *Match) FirstRelationshipPattern() *RelationshipPattern

func (*Match) NewPatternPart added in v0.1.4

func (s *Match) NewPatternPart() *PatternPart

func (*Match) NewWhere added in v0.1.4

func (s *Match) NewWhere() *Where

type Merge

type Merge struct {
	PatternPart  *PatternPart
	MergeActions []*MergeAction
}

type MergeAction

type MergeAction struct {
	OnCreate bool
	OnMatch  bool
	Set      *Set
}

type MultiPartQuery

type MultiPartQuery struct {
	Parts           []*MultiPartQueryPart
	SinglePartQuery *SinglePartQuery
}

func NewMultiPartQuery

func NewMultiPartQuery() *MultiPartQuery

func (*MultiPartQuery) AppendPart

func (s *MultiPartQuery) AppendPart()

func (*MultiPartQuery) CurrentPart

func (s *MultiPartQuery) CurrentPart() *MultiPartQueryPart

type MultiPartQueryPart

type MultiPartQueryPart struct {
	ReadingClauses  []*ReadingClause
	UpdatingClauses []*UpdatingClause
	With            *With
}

func NewMultiPartQueryPart

func NewMultiPartQueryPart() *MultiPartQueryPart

func (*MultiPartQueryPart) AddReadingClause

func (s *MultiPartQueryPart) AddReadingClause(clause *ReadingClause)

func (*MultiPartQueryPart) AddUpdatingClause

func (s *MultiPartQueryPart) AddUpdatingClause(clause *UpdatingClause)

type Negation

type Negation struct {
	Expression Expression
}

func NewNegation

func NewNegation(expression Expression) *Negation

type NodePattern

type NodePattern struct {
	Variable   *Variable
	Kinds      graph.Kinds
	Properties Expression
}

NodePattern

func (*NodePattern) AddKind

func (s *NodePattern) AddKind(kind graph.Kind)

type Operator

type Operator string

func ParseOperator

func ParseOperator(operator string) (Operator, error)

func (Operator) String

func (s Operator) String() string

type Order

type Order struct {
	Items []*SortItem
}

func (*Order) AddItem

func (s *Order) AddItem(item *SortItem)

type Parameter

type Parameter struct {
	Symbol string
	Value  any
}

func NewParameter

func NewParameter(symbol string, value any) *Parameter

type Parenthetical

type Parenthetical struct {
	Expression Expression
}

func NewParenthetical

func NewParenthetical(expression Expression) *Parenthetical

type PartialArithmeticExpression

type PartialArithmeticExpression struct {
	Operator Operator
	Right    Expression
}

func NewArithmeticExpressionPart

func NewArithmeticExpressionPart(operator Operator) *PartialArithmeticExpression

type PartialComparison

type PartialComparison struct {
	Operator Operator
	Right    Expression
}

func NewPartialComparison added in v0.1.4

func NewPartialComparison(operator Operator, right Expression) *PartialComparison

type PatternElement

type PatternElement struct {
	Element Expression
}

func (*PatternElement) AsNodePattern

func (s *PatternElement) AsNodePattern() (*NodePattern, bool)

func (*PatternElement) AsRelationshipPattern

func (s *PatternElement) AsRelationshipPattern() (*RelationshipPattern, bool)

func (*PatternElement) IsNodePattern

func (s *PatternElement) IsNodePattern() bool

func (*PatternElement) IsRelationshipPattern

func (s *PatternElement) IsRelationshipPattern() bool

type PatternPart

type PatternPart struct {
	Variable                *Variable
	ShortestPathPattern     bool
	AllShortestPathsPattern bool
	PatternElements         []*PatternElement
}

func NewPatternPart

func NewPatternPart() *PatternPart

func (*PatternPart) AddPatternElements

func (s *PatternPart) AddPatternElements(nextElements ...Expression) *PatternPart

func (*PatternPart) CurrentElement

func (s *PatternPart) CurrentElement() any

type PatternPredicate

type PatternPredicate struct {
	PatternElements []*PatternElement
}

func NewPatternPredicate

func NewPatternPredicate() *PatternPredicate

func (*PatternPredicate) AddElement

func (s *PatternPredicate) AddElement(element Expression)

type PatternRange

type PatternRange struct {
	StartIndex *int64
	EndIndex   *int64
}

func NewPatternRange

func NewPatternRange(start, end *int64) *PatternRange

type Projection

type Projection struct {
	Distinct bool
	All      bool
	Order    *Order
	Skip     *Skip
	Limit    *Limit
	Items    []Expression
}

func NewProjection

func NewProjection(distinct bool) *Projection

func (*Projection) AddItem

func (s *Projection) AddItem(item *ProjectionItem)

type ProjectionItem

type ProjectionItem struct {
	Expression Expression
	Alias      *Variable
}

func NewGreedyProjectionItem

func NewGreedyProjectionItem() *ProjectionItem

func NewProjectionItem

func NewProjectionItem() *ProjectionItem

func NewProjectionItemWithExpr added in v0.1.4

func NewProjectionItemWithExpr(expr Expression) *ProjectionItem

type Properties

type Properties struct {
	Map       MapLiteral
	Parameter *Parameter
}

func NewProperties

func NewProperties() *Properties

type PropertyLookup

type PropertyLookup struct {
	Atom   Expression
	Symbol string
}

func NewPropertyLookup

func NewPropertyLookup(variableSymbol string, propertySymbol string) *PropertyLookup

func (*PropertyLookup) SetSymbol

func (s *PropertyLookup) SetSymbol(symbol string)

type Quantifier

type Quantifier struct {
	Type   QuantifierType
	Filter *FilterExpression
}

func NewQuantifier

func NewQuantifier(quantifierType QuantifierType) *Quantifier

type QuantifierType

type QuantifierType string

func (QuantifierType) String

func (s QuantifierType) String() string

type RangeQuantifier

type RangeQuantifier struct {
	Value string
}

func NewRangeQuantifier

func NewRangeQuantifier(value string) *RangeQuantifier

type ReadingClause

type ReadingClause struct {
	Match  *Match
	Unwind *Unwind
}

func NewReadingClause

func NewReadingClause() *ReadingClause

func (*ReadingClause) NewMatch added in v0.1.4

func (s *ReadingClause) NewMatch(optional bool) *Match

type RegularQuery

type RegularQuery struct {
	SingleQuery *SingleQuery
}

func NewRegularQuery

func NewRegularQuery() *RegularQuery

type RelationshipPattern

type RelationshipPattern struct {
	Variable   *Variable
	Kinds      graph.Kinds
	Direction  graph.Direction
	Range      *PatternRange
	Properties Expression
}

RelationshipPattern

func (*RelationshipPattern) AddKind

func (s *RelationshipPattern) AddKind(kind graph.Kind)

type Remove

type Remove struct {
	Items []*RemoveItem
}

func NewRemove

func NewRemove(items []*RemoveItem) *Remove

type RemoveItem

type RemoveItem struct {
	KindMatcher *KindMatcher
	Property    Expression
}

func RemoveKindsByMatcher added in v0.1.4

func RemoveKindsByMatcher(kindMatcher *KindMatcher) *RemoveItem

func RemoveProperty added in v0.1.4

func RemoveProperty(propertyLookup Expression) *RemoveItem

type Return

type Return struct {
	Projection *Projection
}

func NewReturn

func NewReturn() *Return

func (*Return) NewProjection added in v0.1.4

func (s *Return) NewProjection(distinct bool) *Projection

type Set

type Set struct {
	Items []*SetItem
}

func NewSet

func NewSet(items []*SetItem) *Set

type SetItem

type SetItem struct {
	Left     Expression
	Operator AssignmentOperator
	Right    Expression
}

func NewSetItem

func NewSetItem(lOperand Expression, operator AssignmentOperator, rOperand Expression) *SetItem

type SinglePartQuery

type SinglePartQuery struct {
	ReadingClauses  []*ReadingClause
	UpdatingClauses []Expression
	Return          *Return
	// contains filtered or unexported fields
}

func NewSinglePartQuery

func NewSinglePartQuery() *SinglePartQuery

func (*SinglePartQuery) AddError

func (s *SinglePartQuery) AddError(err error)

func (*SinglePartQuery) AddReadingClause

func (s *SinglePartQuery) AddReadingClause(clause *ReadingClause)

func (*SinglePartQuery) AddUpdatingClause

func (s *SinglePartQuery) AddUpdatingClause(clause *UpdatingClause)

func (*SinglePartQuery) Errors

func (s *SinglePartQuery) Errors() []error

func (*SinglePartQuery) NewMatch added in v0.1.4

func (s *SinglePartQuery) NewMatch(optional bool) *Match

func (*SinglePartQuery) NewProjection added in v0.1.4

func (s *SinglePartQuery) NewProjection(distinct bool) *Projection

func (*SinglePartQuery) NewReadingClause added in v0.1.4

func (s *SinglePartQuery) NewReadingClause() *ReadingClause

type SingleQuery

type SingleQuery struct {
	SinglePartQuery *SinglePartQuery
	MultiPartQuery  *MultiPartQuery
}

func NewSingleQuery

func NewSingleQuery() *SingleQuery

type Skip

type Skip struct {
	Value Expression
}

func NewSkip

func NewSkip(skip int) *Skip

type SortItem

type SortItem struct {
	Ascending  bool
	Expression Expression
}

type SortOrder

type SortOrder string

func (SortOrder) String

func (s SortOrder) String() string

type SyntaxNode

type SyntaxNode any

type UnaryAddOrSubtractExpression

type UnaryAddOrSubtractExpression struct {
	Operator Operator
	Right    Expression
}

func NewUnaryAddOrSubtractExpression

func NewUnaryAddOrSubtractExpression() *UnaryAddOrSubtractExpression

type Unwind

type Unwind struct {
	Expression Expression
	Variable   *Variable
}

func NewUnwind

func NewUnwind() *Unwind

type UpdatingClause

type UpdatingClause struct {
	Clause Expression
	// contains filtered or unexported fields
}

func NewUpdatingClause

func NewUpdatingClause[T *Delete | *Remove | *Set | *Create | *Merge](clause T) *UpdatingClause

func (*UpdatingClause) AddError

func (s *UpdatingClause) AddError(err error)

func (*UpdatingClause) Errors

func (s *UpdatingClause) Errors() []error

type Variable

type Variable struct {
	Symbol string
}

func NewVariable

func NewVariable() *Variable

func NewVariableWithSymbol

func NewVariableWithSymbol(symbol string) *Variable

type Where

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

func NewWhere

func NewWhere() *Where

func (*Where) Add

func (s *Where) Add(expression Expression)

func (*Where) AddSlice

func (s *Where) AddSlice(expressions []Expression)

func (*Where) Get

func (s *Where) Get(index int) Expression

func (*Where) GetAll

func (s *Where) GetAll() []Expression

func (*Where) IndexOf

func (s *Where) IndexOf(expressionToFind Expression) int

func (*Where) Len

func (s *Where) Len() int

func (*Where) Remove

func (s *Where) Remove(expressionToRemove Expression) bool

func (*Where) Replace

func (s *Where) Replace(index int, expression Expression)

type With

type With struct {
	Projection *Projection
	Where      *Where
}

func NewWith

func NewWith() *With

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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