Documentation ¶
Overview ¶
Package dsl provide an API for writing gremlin dsl queries almost as-is in Go without using strings in the code.
Note that, the API is not type-safe and assume the provided query and its arguments are valid.
Index ¶
- Variables
- type Bindings
- type Block
- type Cardinality
- type Column
- type Func
- type Keyword
- type List
- type Node
- type Order
- type Querier
- type Scope
- type Token
- type Traversal
- func (t *Traversal) Add(n ...Node) *Traversal
- func (t *Traversal) AddE(args ...any) *Traversal
- func (t *Traversal) AddError(err error) *Traversal
- func (t *Traversal) AddV(args ...any) *Traversal
- func (t *Traversal) And(args ...any) *Traversal
- func (t *Traversal) As(args ...any) *Traversal
- func (t *Traversal) Both(args ...any) *Traversal
- func (t *Traversal) BothE(args ...any) *Traversal
- func (t *Traversal) By(args ...any) *Traversal
- func (t *Traversal) Choose(args ...any) *Traversal
- func (t *Traversal) Clone() *Traversal
- func (t *Traversal) Coalesce(args ...any) *Traversal
- func (t *Traversal) Constant(args ...any) *Traversal
- func (t *Traversal) Count(args ...any) *Traversal
- func (t *Traversal) Dedup(args ...any) *Traversal
- func (t *Traversal) Drop() *Traversal
- func (t *Traversal) E(args ...any) *Traversal
- func (t *Traversal) Err() error
- func (t *Traversal) Fold() *Traversal
- func (t *Traversal) From(args ...any) *Traversal
- func (t *Traversal) Group() *Traversal
- func (t *Traversal) Has(args ...any) *Traversal
- func (t *Traversal) HasID(args ...any) *Traversal
- func (t *Traversal) HasLabel(args ...any) *Traversal
- func (t *Traversal) HasNext() *Traversal
- func (t *Traversal) HasNot(args ...any) *Traversal
- func (t *Traversal) ID() *Traversal
- func (t *Traversal) In(args ...any) *Traversal
- func (t *Traversal) InE(args ...any) *Traversal
- func (t *Traversal) InV(args ...any) *Traversal
- func (t *Traversal) Is(args ...any) *Traversal
- func (t *Traversal) Iterate() *Traversal
- func (t *Traversal) Label() *Traversal
- func (t *Traversal) Limit(args ...any) *Traversal
- func (t *Traversal) Match(args ...any) *Traversal
- func (t *Traversal) Max(args ...any) *Traversal
- func (t *Traversal) Mean(args ...any) *Traversal
- func (t *Traversal) Min(args ...any) *Traversal
- func (t *Traversal) Next() *Traversal
- func (t *Traversal) Not(args ...any) *Traversal
- func (t *Traversal) Or(args ...any) *Traversal
- func (t *Traversal) Order(args ...any) *Traversal
- func (t *Traversal) OtherV() *Traversal
- func (t *Traversal) Out(args ...any) *Traversal
- func (t *Traversal) OutE(args ...any) *Traversal
- func (t *Traversal) OutV(args ...any) *Traversal
- func (t *Traversal) Properties(args ...any) *Traversal
- func (t *Traversal) Property(args ...any) *Traversal
- func (t *Traversal) Query() (string, Bindings)
- func (t *Traversal) Range(args ...any) *Traversal
- func (t *Traversal) Select(args ...any) *Traversal
- func (t *Traversal) SideEffect(args ...any) *Traversal
- func (t *Traversal) Sum(args ...any) *Traversal
- func (t *Traversal) To(args ...any) *Traversal
- func (t *Traversal) ToList() *Traversal
- func (t *Traversal) Undo() *Traversal
- func (t *Traversal) Unfold() *Traversal
- func (t *Traversal) Union(args ...any) *Traversal
- func (t *Traversal) V(args ...any) *Traversal
- func (t *Traversal) ValueMap(args ...any) *Traversal
- func (t *Traversal) Values(args ...string) *Traversal
- func (t *Traversal) Where(args ...any) *Traversal
- type Var
Constants ¶
This section is empty.
Variables ¶
var ( G = Token("g") Dot = Token(".") )
predefined nodes.
Functions ¶
This section is empty.
Types ¶
type Cardinality ¶
type Cardinality string
Cardinality of vertex properties.
const ( Set Cardinality = "set" Single Cardinality = "single" )
Cardinality options.
func (Cardinality) Code ¶
func (c Cardinality) Code() (string, []any)
Code implements the Node interface.
type Column ¶
type Column string
Column references a particular type of column in a complex data structure such as a Map, a Map.Entry, or a Path.
type Keyword ¶
type Keyword string
Keyword defines a Gremlin keyword.
const (
ID Keyword = "id"
)
Keyword options.
type Node ¶
type Node interface { // Code returns the code representation of the element and its bindings (if any). Code() (string, []any) }
Node represents a DSL step in the traversal.
type Querier ¶
type Querier interface { // Query returns the query-string (similar to the Gremlin byte-code) and its bindings. Query() (string, Bindings) }
Querier is the interface that wraps the Query method.
type Scope ¶
type Scope string
Scope used for steps that have a variable scope which alter the manner in which the step will behave in relation to how the traverses are processed.
type Traversal ¶
type Traversal struct {
// contains filtered or unexported fields
}
Traversal mimics the TinkerPop graph traversal.
func Group ¶
Group groups a list of traversals into one. all traversals are assigned into a temporary variables named by their index. The last variable functions as a return value of the query. Note that, this "temporary hack" is not perfect and may not work in some cases because of the limitation of evaluation order.
func NewTraversal ¶
func NewTraversal() *Traversal
NewTraversal returns a new default traversal with "g" as a reference name to the Graph.
func (*Traversal) Add ¶
Add is the public API for adding new nodes to the traversal by its sub packages.
func (*Traversal) As ¶
As provides a label to the step that can be accessed later in the traversal by other steps.
func (*Traversal) By ¶
By can be applied to a number of different step to alter their behaviors. This form is essentially an identity() modulation.
func (*Traversal) Choose ¶
Choose routes the current traverser to a particular traversal branch option which allows the creation of if-then-else like semantics within a traversal.
func (*Traversal) Coalesce ¶
Coalesce evaluates the provided traversals and returns the result of the first traversal to emit at least one object.
func (*Traversal) Count ¶
Count maps the traversal stream to its reduction as a sum of the Traverser.bulk() values (i.e. count the number of traversers up to this point).
func (*Traversal) E ¶
E step is usually used to start a traversal but it may also be used mid-traversal.
func (*Traversal) Err ¶
Err returns a concatenated error of all errors encountered during the query-building, or were added manually by calling AddError.
func (*Traversal) Group ¶
Group organizes objects in the stream into a Map.Calls to group() are typically accompanied with by() modulators which help specify how the grouping should occur.
func (*Traversal) Has ¶
Has filters vertices, edges and vertex properties based on their properties. See: http://tinkerpop.apache.org/docs/current/reference/#has-step.
func (*Traversal) HasID ¶
HasID filters vertices, edges and vertex properties based on their identifier.
func (*Traversal) HasLabel ¶
HasLabel filters vertices, edges and vertex properties based on their label.
func (*Traversal) HasNot ¶
HasNot filters vertices, edges and vertex properties based on the non-existence of properties. See: http://tinkerpop.apache.org/docs/current/reference/#has-step.
func (*Traversal) Iterate ¶
Iterate iterates the traversal presumably for the generation of side-effects.
func (*Traversal) Limit ¶
Limit filters the objects in the traversal by the number of them to pass through the stream, where only the first n objects are allowed as defined by the limit argument.
func (*Traversal) Match ¶
Match maps the Traverser to a Map of bindings as specified by the provided match traversals.
func (*Traversal) Not ¶
Not removes objects from the traversal stream when the traversal provided as an argument does not return any objects.
func (*Traversal) Order ¶
Order all the objects in the traversal up to this point and then emit them one-by-one in their ordered sequence.
func (*Traversal) OtherV ¶
OtherV maps the Edge to the incident vertex that was not just traversed from in the path history.
func (*Traversal) Out ¶
Out maps the Vertex to its outgoing adjacent vertices given the edge labels.
func (*Traversal) Properties ¶
Properties maps the Element to its associated properties given the provide property keys.
func (*Traversal) Property ¶
Property sets a Property value and related meta properties if supplied, if supported by the Graph and if the Element is a VertexProperty.
func (*Traversal) Query ¶
Query returns the query-representation and its binding of this traversal object.
func (*Traversal) Range ¶
Range filters the objects in the traversal by the number of them to pass through the stream.
func (*Traversal) SideEffect ¶
SideEffect allows the traverser to proceed unchanged, but yield some computational sideEffect in the process.
func (*Traversal) Sum ¶
Sum maps the traversal stream to its reduction as a sum of the Traverser.get() values multiplied by their Traverser.bulk().
func (*Traversal) To ¶
To used as a modifier to addE(String) this method specifies the traversal to use for selecting the incoming vertex of the newly added Edge.
func (*Traversal) Unfold ¶
Unfold unrolls a Iterator, Iterable or Map into a linear form or simply emits the object if it is not one of those types.
func (*Traversal) V ¶
V step is usually used to start a traversal but it may also be used mid-traversal.
func (*Traversal) ValueMap ¶
ValueMap maps the Element to a Map of the property values key'd according to their Property.key().