Gremlex.Graph (gremlex v0.4.3)

View Source

Functions for traversing and mutating the Graph.

Graph operations are stored in a queue which can be created with g/0. Mosts functions return the queue so that they can be chained together similar to how Gremlin queries work.

Example:

g.V(1).values("name")

Would translate to

g |> v(1) |> values("name")

Note: This module doesn't actually execute any queries, it just allows you to build one. For query execution see Gremlex.Client.query/1

Summary

Functions

Appends an addE command to the traversal. Returns a graph to allow chaining.

Adds a namespace as property

Appends an addV command to the traversal. Returns a graph to allow chaining.

Appends an aggregate command to the traversal. Returns a graph to allow chaining.

Appends a coin command to the traversal. Takes in a graph and a probability modifier as parameters. Returns a graph to allow chaining.

Appends values the E command allowing you to select an edge. Returns a graph to allow chaining.

Compiles a graph into the Gremlin query.

g()

Start of graph traversal. All graph operations are stored in a queue.

Appends groupCount command to the traversal. Takes in a graph and the name of the key that will hold the aggregated grouping. Returns a graph to allow chainig.

Appends properties command to the traversal. Returns a graph to allow chaining.

Appends property command to the traversal. Returns a graph to allow chaining.

Appends sideEffect command to the traversal.

Appends the store command to the traversal. Takes in a graph and the name of the side effect key that will hold the aggregate. Returns a graph to allow chaining.

Appends values the V command allowing you to select a vertex. Returns a graph to allow chaining.

Appends values the V command allowing you to select a vertex. Returns a graph to allow chaining.

Appends valueMap command to the traversal. Returns a graph to allow chaining.

Appends values command to the traversal. Returns a graph to allow chaining.

Creates a within predicate that will match at least one of the values provided. Takes in a range or a list as the values. Examples

Creates a without predicate that will filter out values that match the values provided. Takes in a range or a list as the values. Examples

Types

t()

@opaque t()

Functions

add_e(graph, edge)

@spec add_e(t(), any()) :: t()

Appends an addE command to the traversal. Returns a graph to allow chaining.

add_namespace(graph)

@spec add_namespace(t()) :: t()

Adds a namespace as property

add_namespace(graph, ns)

@spec add_namespace(t(), any()) :: t()

add_v(graph, id)

@spec add_v(t(), any()) :: t()

Appends an addV command to the traversal. Returns a graph to allow chaining.

aggregate(graph, aggregate)

@spec aggregate(t(), String.t()) :: t()

Appends an aggregate command to the traversal. Returns a graph to allow chaining.

and_(graph)

@spec and_(t()) :: t()

anonymous()

@spec anonymous() :: t()

as(graph, name)

@spec as(t(), list() | String.t()) :: t()

barrier(graph)

@spec barrier(t()) :: t()

barrier(graph, max_barrier_size)

@spec barrier(t(), non_neg_integer()) :: t()

both(graph)

@spec both(t()) :: t()

both(graph, labels)

@spec both(t(), list()) :: t()
@spec both(t(), String.t()) :: t()

both_e(graph)

@spec both_e(t()) :: t()

both_e(graph, labels)

@spec both_e(t(), String.t() | list()) :: t()

both_v(graph)

@spec both_v(t()) :: t()

both_v(graph, labels)

@spec both_v(t(), list() | String.t()) :: t()

by(graph)

@spec by(t()) :: t()

by(graph, value)

@spec by(t(), list() | String.t() | t()) :: t()

by(graph, value, ordering)

@spec by(t(), list() | String.t() | t(), atom()) :: t()

cap(graph, cap)

@spec cap(t(), String.t()) :: t()

choose(graph, predicate, traversals)

@spec choose(t(), t(), [t()]) :: t()

coalesce(graph, traversals)

@spec coalesce(t(), list() | String.t()) :: t()

coin(graph, probability)

@spec coin(t(), float()) :: t()

Appends a coin command to the traversal. Takes in a graph and a probability modifier as parameters. Returns a graph to allow chaining.

constant(graph, constant)

@spec constant(t(), String.t()) :: t()

count(graph)

@spec count(t()) :: t()
@spec count(t()) :: t()

count(graph, arg)

cyclic_path(graph)

@spec cyclic_path(t()) :: t()

datetime(graph, iso_date_string)

@spec datetime(t(), String.t()) :: t()

dedup(graph)

@spec dedup(t()) :: t()

drop(graph)

@spec drop(t()) :: t()

e(graph)

@spec e(t()) :: t()

Appends values the E command allowing you to select an edge. Returns a graph to allow chaining.

e(graph, id)

@spec e(t(), Gremlex.Edge.t()) :: t()
@spec e(t(), number() | String.t() | [number()] | [String.t()]) :: t()

emit(graph)

@spec emit(t()) :: t()

emit(graph, traversal)

@spec emit(t(), t()) :: t()

encode(graph)

@spec encode(t()) :: String.t()

Compiles a graph into the Gremlin query.

eq(graph, number)

@spec eq(t(), number()) :: t()

fold(graph)

@spec fold(t()) :: t()

fold(graph, traversal)

@spec fold(t(), any()) :: t()

from(graph, name)

@spec from(t(), String.t()) :: t()

g()

@spec g() :: t()

Start of graph traversal. All graph operations are stored in a queue.

group(graph)

@spec group(t()) :: t()

group_count(graph)

@spec group_count(t()) :: t()

group_count(graph, key)

@spec group_count(t(), String.t()) :: t()

Appends groupCount command to the traversal. Takes in a graph and the name of the key that will hold the aggregated grouping. Returns a graph to allow chainig.

gt(graph, number)

@spec gt(t(), number()) :: t()

gte(graph, number)

@spec gte(t(), number()) :: t()

has(graph, key)

@spec has(t(), any()) :: t()

has(graph, key, value)

@spec has(t(), any(), any()) :: t()

has_id(graph, id)

@spec has_id(t(), any()) :: t()

has_key(graph, key)

@spec has_key(t(), list() | String.t()) :: t()

has_label(graph, label)

@spec has_label(t(), String.t() | [String.t()]) :: t()

has_namespace(graph)

@spec has_namespace(t()) :: t()

has_namespace(graph, ns)

@spec has_namespace(t(), any()) :: t()

has_next(graph)

@spec has_next(t()) :: t()

has_not(graph, key)

@spec has_not(t(), String.t()) :: t()

id(graph)

@spec id(t()) :: t()

identity(graph)

@spec identity(t()) :: t()

in_(graph)

in_(graph, edge)

@spec in_(t(), String.t()) :: t()
@spec in_(t(), String.t()) :: t()

in_e(graph)

@spec in_e(t()) :: t()

in_e(graph, edges)

@spec in_e(t(), String.t() | list()) :: t()

in_v(graph)

@spec in_v(t()) :: t()

in_v(graph, labels)

@spec in_v(t(), String.t() | list()) :: t()

inject(graph, target)

@spec inject(t(), String.t()) :: t()

is(graph, value)

@spec is(t(), any()) :: t()

iterate(graph)

@spec iterate(t()) :: t()

key(graph)

@spec key(t()) :: t()

label(graph)

@spec label(t()) :: t()

limit(graph, limit)

@spec limit(t(), integer()) :: t()

limit(graph, arg, limit)

@spec limit(t(), String.t(), integer()) :: t()

local(graph, traversal)

@spec local(t(), t()) :: t()

loops(graph)

@spec loops(t()) :: t()

lt(graph, number)

@spec lt(t(), number()) :: t()

max(graph)

@spec max(t()) :: t()

min(graph)

@spec min(t()) :: t()

next(graph)

@spec next(t()) :: t()

next(graph, numberOfResults)

@spec next(t(), number()) :: t()

not_(graph, traversal)

@spec not_(t(), any()) :: t()

or_(graph)

@spec or_(t()) :: t()

order(graph)

@spec order(t()) :: t()

other_v(graph)

@spec other_v(t()) :: t()

out(graph)

@spec out(t()) :: t()

out(graph, labels)

@spec out(t(), String.t() | list()) :: t()

out_e(graph)

@spec out_e(t()) :: t()

out_e(graph, edges)

@spec out_e(t(), String.t() | list()) :: t()

out_v(graph)

@spec out_v(t()) :: t()

out_v(graph, labels)

@spec out_v(t(), String.t() | list()) :: t()

path(graph)

@spec path(t()) :: t()

project(graph, list)

@spec project(t(), list()) :: t()

properties(graph)

@spec properties(t()) :: t()

properties(graph, key)

@spec properties(t(), String.t()) :: t()

Appends properties command to the traversal. Returns a graph to allow chaining.

property(graph, key)

@spec property(t(), String.t()) :: t()

property(graph, key, value)

@spec property(t(), String.t() | atom(), any()) :: t()

Appends property command to the traversal. Returns a graph to allow chaining.

property(graph, atom, key, value)

@spec property(t(), atom(), String.t(), any()) :: t()
@spec property(t(), atom(), String.t(), any()) :: t()
@spec property(t(), atom(), String.t(), any()) :: t()

range(graph, from, to)

range(graph, arg, from, to)

@spec range(t(), String.t(), integer(), integer()) :: t()
@spec range(t(), String.t(), integer(), integer()) :: t()

repeat(graph, traversal)

@spec repeat(t(), t()) :: t()

select(graph, names)

@spec select(t(), list() | String.t()) :: t()

side_effect(graph, key)

@spec side_effect(t(), t() | String.t()) :: t()

Appends sideEffect command to the traversal.

The side effect is a way to store the result of a traversal in a key that can be used later in the traversal. It is similar to a variable that can be used to store intermediate results.

Example:

g.V()
  .hasLabel('Product')
  .has('price', gt(100))
  .sideEffect(__.property('discounted', true))

simple_path(graph)

@spec simple_path(t()) :: t()

store(graph, store)

@spec store(t(), String.t()) :: t()

Appends the store command to the traversal. Takes in a graph and the name of the side effect key that will hold the aggregate. Returns a graph to allow chaining.

sum(graph)

@spec sum(t()) :: t()

tail(graph)

@spec tail(t()) :: t()

tail(graph, size)

@spec tail(t(), non_neg_integer()) :: t()

times(graph, num)

@spec times(t(), integer()) :: t()

to(graph, target)

@spec to(t(), String.t() | number() | Gremlex.Vertex.t()) :: t()

to_bulk_set(graph)

@spec to_bulk_set(t()) :: t()

to_list(graph)

@spec to_list(t()) :: t()

to_set(graph)

@spec to_set(t()) :: t()

try_next(graph)

@spec try_next(t()) :: t()

unfold(graph)

@spec unfold(t()) :: t()

unfold(graph, traversal)

@spec unfold(t(), any()) :: t()

union(graph, list)

@spec union(t(), list()) :: t()

until(graph, traversal)

@spec until(t(), t()) :: t()

v(graph_or_id)

@spec v(t() | number() | String.t()) :: t() | Gremlex.Vertex.t()

Appends values the V command allowing you to select a vertex. Returns a graph to allow chaining.

v(graph, id)

@spec v(t(), Gremlex.Vertex.t()) :: t()
@spec v(t(), number()) :: t()
@spec v(t(), list() | String.t()) :: t()

Appends values the V command allowing you to select a vertex. Returns a graph to allow chaining.

value_map(graph)

@spec value_map(t()) :: t()

Appends valueMap command to the traversal. Returns a graph to allow chaining.

value_map(graph, value)

@spec value_map(t(), boolean()) :: t()
@spec value_map(t(), String.t()) :: t()
@spec value_map(t(), [String.t()]) :: t()

values(graph, key)

@spec values(t(), String.t()) :: t()

Appends values command to the traversal. Returns a graph to allow chaining.

where(graph, traversal)

@spec where(t(), any()) :: t()

within(range)

Creates a within predicate that will match at least one of the values provided. Takes in a range or a list as the values. Examples:

g.V().has('age', within(1..18))
g.V().has('name', within(["some", "value"]))

without(range)

Creates a without predicate that will filter out values that match the values provided. Takes in a range or a list as the values. Examples:

g.V().has('age', without(18..30))
g.V().has('name', without(["any", "value"]))