ent: github.com/facebookincubator/ent/dialect/gremlin/graph/dsl Index | Files | Directories

package dsl

import "github.com/facebookincubator/ent/dialect/gremlin/graph/dsl"

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

Package Files

dsl.go traversal.go

Variables

var (
    G   = Token("g")
    Dot = Token(".")
)

predefined nodes.

type Bindings Uses

type Bindings map[string]interface{}

Bindings are used to associate a variable with a value.

func (Bindings) Add Uses

func (b Bindings) Add(v interface{}) string

Add adds new value to the bindings map, formats it if needed, and returns its generated name.

type Block Uses

type Block struct {
    Nodes []interface{}
}

Block represents a block/group of nodes.

func (Block) Code Uses

func (b Block) Code() (string, []interface{})

Code returns the code representation of group/block of nodes.

type Cardinality Uses

type Cardinality string

Cardinality of vertex properties.

const (
    Set    Cardinality = "set"
    Single Cardinality = "single"
)

Cardinality options.

func (Cardinality) Code Uses

func (c Cardinality) Code() (string, []interface{})

Code implements the Node interface.

type Column Uses

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.

const (
    Keys   Column = "keys"
    Values Column = "values"
)

Column options.

func (Column) Code Uses

func (o Column) Code() (string, []interface{})

Code implements the Node interface.

type Func Uses

type Func struct {
    Name string
    Args []interface{}
}

Func represents a function call.

func NewFunc Uses

func NewFunc(name string, args ...interface{}) *Func

NewFunc returns a new function node.

func (Func) Code Uses

func (f Func) Code() (string, []interface{})

Code returns the code representation of a function call.

type List Uses

type List struct {
    Elements []interface{}
}

List represents a list of elements.

func NewList Uses

func NewList(args ...interface{}) *List

NewList returns a new list node.

func (List) Code Uses

func (l List) Code() (string, []interface{})

Code returns the code representation of a list.

type Node Uses

type Node interface {
    // Code returns the code representation of the element and its bindings (if any).
    Code() (string, []interface{})
}

Node represents a DSL step in the traversal.

type Order Uses

type Order string

Order of vertex properties.

const (
    Incr    Order = "incr"
    Decr    Order = "decr"
    Shuffle Order = "shuffle"
)

Order options.

func (Order) Code Uses

func (o Order) Code() (string, []interface{})

Code implements the Node interface.

type Querier Uses

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 Uses

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.

const (
    Local  Scope = "local"
    Global Scope = "global"
)

Scope options.

func (Scope) Code Uses

func (s Scope) Code() (string, []interface{})

Code implements the Node interface.

type Token Uses

type Token string

Token holds a simple token, like assignment.

func (Token) Code Uses

func (t Token) Code() (string, []interface{})

Code stringified the token.

type Traversal Uses

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

Traversal mimics the TinkerPop graph traversal.

func Each Uses

func Each(v interface{}, cb func(it *Traversal) *Traversal) *Traversal

Each is a Groovy each-loop function.

func Group Uses

func Group(trs ...*Traversal) *Traversal

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 Join Uses

func Join(trs ...*Traversal) *Traversal

Join joins a list of traversals with a semicolon separator.

func NewTraversal Uses

func NewTraversal() *Traversal

NewTraversal returns a new default traversal with "g" as a reference name to the Graph.

func (*Traversal) Add Uses

func (t *Traversal) Add(n ...Node) *Traversal

Add is the public API for adding new nodes to the traversal by its sub packages.

func (*Traversal) AddE Uses

func (t *Traversal) AddE(args ...interface{}) *Traversal

AddE adds an edge.

func (*Traversal) AddV Uses

func (t *Traversal) AddV(args ...interface{}) *Traversal

AddV adds a vertex.

func (*Traversal) And Uses

func (t *Traversal) And(args ...interface{}) *Traversal

And ensures that all of the provided traversals yield a result.

func (*Traversal) As Uses

func (t *Traversal) As(args ...interface{}) *Traversal

As provides a label to the step that can be accessed later in the traversal by other steps.

func (*Traversal) Both Uses

func (t *Traversal) Both(args ...interface{}) *Traversal

Both maps the Vertex to its adjacent vertices given the edge labels.

func (*Traversal) BothE Uses

func (t *Traversal) BothE(args ...interface{}) *Traversal

BothE maps the Vertex to its incident edges given the edge labels.

func (*Traversal) By Uses

func (t *Traversal) By(args ...interface{}) *Traversal

By can be applied to a number of different step to alter their behaviors. This form is essentially an identity() modulation.

func (*Traversal) Choose Uses

func (t *Traversal) Choose(args ...interface{}) *Traversal

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) Clone Uses

func (t *Traversal) Clone() *Traversal

Clone creates a deep copy of an existing traversal.

func (*Traversal) Coalesce Uses

func (t *Traversal) Coalesce(args ...interface{}) *Traversal

Coalesce evaluates the provided traversals and returns the result of the first traversal to emit at least one object.

func (*Traversal) Constant Uses

func (t *Traversal) Constant(args ...interface{}) *Traversal

Constant maps any object to a fixed E value.

func (*Traversal) Count Uses

func (t *Traversal) Count(args ...interface{}) *Traversal

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) Dedup Uses

func (t *Traversal) Dedup(args ...interface{}) *Traversal

Dedup removes all duplicates in the traversal stream up to this point.

func (*Traversal) Drop Uses

func (t *Traversal) Drop() *Traversal

Drop removes elements and properties from the graph.

func (*Traversal) E Uses

func (t *Traversal) E(args ...interface{}) *Traversal

E step is usually used to start a traversal but it may also be used mid-traversal.

func (*Traversal) Fold Uses

func (t *Traversal) Fold() *Traversal

Fold rolls up objects in the stream into an aggregate list..

func (*Traversal) From Uses

func (t *Traversal) From(args ...interface{}) *Traversal

From provides from()-modulation to respective steps.

func (*Traversal) Group Uses

func (t *Traversal) Group() *Traversal

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 Uses

func (t *Traversal) Has(args ...interface{}) *Traversal

Has filters vertices, edges and vertex properties based on their properties. See: http://tinkerpop.apache.org/docs/current/reference/#has-step.

func (*Traversal) HasID Uses

func (t *Traversal) HasID(args ...interface{}) *Traversal

HasID filters vertices, edges and vertex properties based on their identifier.

func (*Traversal) HasLabel Uses

func (t *Traversal) HasLabel(args ...interface{}) *Traversal

HasLabel filters vertices, edges and vertex properties based on their label.

func (*Traversal) HasNext Uses

func (t *Traversal) HasNext() *Traversal

HasNext returns true if the iteration has more elements.

func (*Traversal) HasNot Uses

func (t *Traversal) HasNot(args ...interface{}) *Traversal

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) ID Uses

func (t *Traversal) ID() *Traversal

ID maps the Element to its Element.id().

func (*Traversal) In Uses

func (t *Traversal) In(args ...interface{}) *Traversal

In maps the Vertex to its incoming adjacent vertices given the edge labels.

func (*Traversal) InE Uses

func (t *Traversal) InE(args ...interface{}) *Traversal

InE maps the Vertex to its incoming incident edges given the edge labels.

func (*Traversal) InV Uses

func (t *Traversal) InV(args ...interface{}) *Traversal

InV maps the Edge to its incoming/head incident Vertex.

func (*Traversal) Is Uses

func (t *Traversal) Is(args ...interface{}) *Traversal

Is filters the E object if it is not P.eq(V) to the provided value.

func (*Traversal) Iterate Uses

func (t *Traversal) Iterate() *Traversal

Iterate iterates the traversal presumably for the generation of side-effects.

func (*Traversal) Label Uses

func (t *Traversal) Label() *Traversal

Label maps the Element to its Element.label().

func (*Traversal) Limit Uses

func (t *Traversal) Limit(args ...interface{}) *Traversal

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 Uses

func (t *Traversal) Match(args ...interface{}) *Traversal

Match maps the Traverser to a Map of bindings as specified by the provided match traversals.

func (*Traversal) Max Uses

func (t *Traversal) Max(args ...interface{}) *Traversal

Max determines the greatest value in the stream.

func (*Traversal) Mean Uses

func (t *Traversal) Mean(args ...interface{}) *Traversal

Mean determines the mean value in the stream.

func (*Traversal) Min Uses

func (t *Traversal) Min(args ...interface{}) *Traversal

Min determines the smallest value in the stream.

func (*Traversal) Next Uses

func (t *Traversal) Next() *Traversal

Next gets the next n-number of results from the traversal.

func (*Traversal) Not Uses

func (t *Traversal) Not(args ...interface{}) *Traversal

Not removes objects from the traversal stream when the traversal provided as an argument does not return any objects.

func (*Traversal) Or Uses

func (t *Traversal) Or(args ...interface{}) *Traversal

Or ensures that at least one of the provided traversals yield a result.

func (*Traversal) Order Uses

func (t *Traversal) Order(args ...interface{}) *Traversal

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 Uses

func (t *Traversal) OtherV() *Traversal

OtherV maps the Edge to the incident vertex that was not just traversed from in the path history.

func (*Traversal) Out Uses

func (t *Traversal) Out(args ...interface{}) *Traversal

Out maps the Vertex to its outgoing adjacent vertices given the edge labels.

func (*Traversal) OutE Uses

func (t *Traversal) OutE(args ...interface{}) *Traversal

OutE maps the Vertex to its outgoing incident edges given the edge labels.

func (*Traversal) OutV Uses

func (t *Traversal) OutV(args ...interface{}) *Traversal

OutV maps the Edge to its outgoing/tail incident Vertex.

func (*Traversal) Properties Uses

func (t *Traversal) Properties(args ...interface{}) *Traversal

Properties maps the Element to its associated properties given the provide property keys.

func (*Traversal) Property Uses

func (t *Traversal) Property(args ...interface{}) *Traversal

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 Uses

func (t *Traversal) Query() (string, Bindings)

Query returns the query-representation and its binding of this traversal object.

func (*Traversal) Range Uses

func (t *Traversal) Range(args ...interface{}) *Traversal

Range filters the objects in the traversal by the number of them to pass through the stream.

func (*Traversal) Select Uses

func (t *Traversal) Select(args ...interface{}) *Traversal

Select arbitrary values from the traversal.

func (*Traversal) SideEffect Uses

func (t *Traversal) SideEffect(args ...interface{}) *Traversal

SideEffect allows the traverser to proceed unchanged, but yield some computational sideEffect in the process.

func (*Traversal) Sum Uses

func (t *Traversal) Sum(args ...interface{}) *Traversal

Sum maps the traversal stream to its reduction as a sum of the Traverser.get() values multiplied by their Traverser.bulk().

func (*Traversal) To Uses

func (t *Traversal) To(args ...interface{}) *Traversal

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) ToList Uses

func (t *Traversal) ToList() *Traversal

ToList puts all the results into a Groovy list.

func (*Traversal) Undo Uses

func (t *Traversal) Undo() *Traversal

Undo reverts the last-step of the traversal.

func (*Traversal) Unfold Uses

func (t *Traversal) Unfold() *Traversal

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) Union Uses

func (t *Traversal) Union(args ...interface{}) *Traversal

Union merges the results of an arbitrary number of traversals.

func (*Traversal) V Uses

func (t *Traversal) V(args ...interface{}) *Traversal

V step is usually used to start a traversal but it may also be used mid-traversal.

func (*Traversal) ValueMap Uses

func (t *Traversal) ValueMap(args ...interface{}) *Traversal

ValueMap maps the Element to a Map of the property values key'd according to their Property.key().

func (*Traversal) Values Uses

func (t *Traversal) Values(args ...string) *Traversal

Values maps the Element to the values of the associated properties given the provide property keys.

func (*Traversal) Where Uses

func (t *Traversal) Where(args ...interface{}) *Traversal

Where filters the current object based on the object itself or the path history.

type Var Uses

type Var struct {
    Name string
    Elem interface{}
}

Var represents a variable assignment and usage.

func (Var) Code Uses

func (v Var) Code() (string, []interface{})

Code returns the code representation of variable declaration or its identifier.

Directories

PathSynopsis
__
g
p

Package dsl imports 3 packages (graph) and is imported by 18 packages. Updated 2019-10-02. Refresh now. Tools for package owners.