Arangox.API.Graphs (Arangox v0.8.0)

Copy Markdown View Source

ArangoDB's Graphs operations.

Every function takes the pool as its first argument and returns the decoded response body. See Arangox.API.Client for the options they all accept and for what a 404 returns.

Summary

Functions

Add a node collection. Raises on error.

List all graphs

List all graphs. Raises on error.

List edge collections. Raises on error.

List node collections. Raises on error.

Create a graph. Raises on error.

Add an edge definition. Raises on error.

Drop a graph. Raises on error.

Remove an edge definition. Raises on error.

Remove a node collection. Raises on error.

Get a graph. Raises on error.

Replace an edge definition. Raises on error.

Get inbound and outbound edges. Raises on error.

Functions

add_vertex_collection(conn, graph, body, opts \\ [])

@spec add_vertex_collection(Arangox.conn(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Add a node collection

Adds a node collection to the set of orphan collections of the graph. If the collection does not exist, it is created.

add_vertex_collection!(conn, graph, body, opts \\ [])

@spec add_vertex_collection!(Arangox.conn(), binary(), term(), keyword()) :: term()

Add a node collection. Raises on error.

See add_vertex_collection/3.

all(conn, opts \\ [])

@spec all(
  Arangox.conn(),
  keyword()
) :: {:ok, term()} | {:error, Exception.t()}

List all graphs

Lists all graphs stored in this database.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "graphs" => [%{
    "_id" => string,
    "_key" => string,
    "_rev" => string,
    "edgeDefinitions" => [%{
      "collection" => string,
      "from" => [string],
      "to" => [string]
    }],
    "name" => string,
    "orphanCollections" => []
  }]
}

all!(conn, opts \\ [])

@spec all!(
  Arangox.conn(),
  keyword()
) :: term()

List all graphs. Raises on error.

See all/1.

all_edge_collections(conn, graph, opts \\ [])

@spec all_edge_collections(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

List edge collections

Lists all edge collections within this graph.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "collections" => [string],
  "error" => boolean
}

all_edge_collections!(conn, graph, opts \\ [])

@spec all_edge_collections!(Arangox.conn(), binary(), keyword()) :: term()

List edge collections. Raises on error.

See all_edge_collections/2.

all_vertex_collections(conn, graph, opts \\ [])

@spec all_vertex_collections(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

List node collections

Lists all node collections within this graph, including orphan collections.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "collections" => [string],
  "error" => boolean
}

all_vertex_collections!(conn, graph, opts \\ [])

@spec all_vertex_collections!(Arangox.conn(), binary(), keyword()) :: term()

List node collections. Raises on error.

See all_vertex_collections/2.

create(conn, body, opts \\ [])

@spec create(Arangox.conn(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Create a graph

The creation of a graph requires the name of the graph and a definition of its edges.

create!(conn, body, opts \\ [])

@spec create!(Arangox.conn(), term(), keyword()) :: term()

Create a graph. Raises on error.

See create/2.

create_edge(conn, graph, collection, body, opts \\ [])

@spec create_edge(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Create an edge

Creates a new edge in the specified collection. Within the body the edge has to contain a _from and _to value referencing to valid nodes in the graph. Furthermore, the edge has to be valid according to the edge definitions.

create_edge!(conn, graph, collection, body, opts \\ [])

@spec create_edge!(Arangox.conn(), binary(), binary(), term(), keyword()) :: term()

Create an edge. Raises on error.

See create_edge/4.

create_edge_definition(conn, graph, body, opts \\ [])

@spec create_edge_definition(Arangox.conn(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Add an edge definition

Adds an additional edge definition to the graph.

This edge definition has to contain a collection and an array of each from and to node collections. An edge definition can only be added if this definition is either not used in any other graph, or it is used with exactly the same definition. For example, it is not possible to store a definition "e" from "v1" to "v2" in one graph, and "e" from "v2" to "v1" in another graph, but both can have "e" from "v1" to "v2".

Additionally, collection creation options can be set.

create_edge_definition!(conn, graph, body, opts \\ [])

@spec create_edge_definition!(Arangox.conn(), binary(), term(), keyword()) :: term()

Add an edge definition. Raises on error.

See create_edge_definition/3.

create_vertex(conn, graph, collection, body, opts \\ [])

@spec create_vertex(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Create a node

Adds a node to the given collection.

create_vertex!(conn, graph, collection, body, opts \\ [])

@spec create_vertex!(Arangox.conn(), binary(), binary(), term(), keyword()) :: term()

Create a node. Raises on error.

See create_vertex/4.

delete(conn, graph, opts \\ [])

@spec delete(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Drop a graph

Drops an existing graph object by name. Optionally all collections not used by other graphs can be dropped as well.

delete!(conn, graph, opts \\ [])

@spec delete!(Arangox.conn(), binary(), keyword()) :: term()

Drop a graph. Raises on error.

See delete/2.

delete_edge(conn, graph, collection, edge, opts \\ [])

@spec delete_edge(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Remove an edge

Removes an edge from an edge collection of the named graph. Any other edges that directly reference this edge like a node are removed, too.

delete_edge!(conn, graph, collection, edge, opts \\ [])

@spec delete_edge!(Arangox.conn(), binary(), binary(), binary(), keyword()) :: term()

Remove an edge. Raises on error.

See delete_edge/4.

delete_edge_definition(conn, graph, collection, opts \\ [])

@spec delete_edge_definition(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Remove an edge definition

Remove one edge definition from the graph. This only removes the edge collection from the graph definition. The node collections of the edge definition become orphan collections but otherwise remain untouched and can still be used in your queries.

delete_edge_definition!(conn, graph, collection, opts \\ [])

@spec delete_edge_definition!(Arangox.conn(), binary(), binary(), keyword()) :: term()

Remove an edge definition. Raises on error.

See delete_edge_definition/3.

delete_vertex(conn, graph, collection, vertex, opts \\ [])

@spec delete_vertex(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Remove a node

Removes a node from a collection of the named graph. Additionally removes all incoming and outgoing edges of the node.

delete_vertex!(conn, graph, collection, vertex, opts \\ [])

@spec delete_vertex!(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  term()

Remove a node. Raises on error.

See delete_vertex/4.

delete_vertex_collection(conn, graph, collection, opts \\ [])

@spec delete_vertex_collection(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Remove a node collection

Removes a node collection from the list of the graph's orphan collections. It can optionally delete the collection if it is not used in any other graph.

You cannot remove node collections that are used in one of the edge definitions of the graph. You need to modify or remove the edge definition first in order to fully remove a node collection from the graph.

delete_vertex_collection!(conn, graph, collection, opts \\ [])

@spec delete_vertex_collection!(Arangox.conn(), binary(), binary(), keyword()) ::
  term()

Remove a node collection. Raises on error.

See delete_vertex_collection/3.

get(conn, graph, opts \\ [])

@spec get(Arangox.conn(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Get a graph

Selects information for a given graph. Returns the edge definitions as well as the orphan collections, or returns an error if the graph does not exist.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "graph" => %{
    "_id" => string,
    "_key" => string,
    "_rev" => string,
    "edgeDefinitions" => [%{
      "collection" => string,
      "from" => [string],
      "to" => [string]
    }],
    "name" => string,
    "orphanCollections" => []
  }
}

get!(conn, graph, opts \\ [])

@spec get!(Arangox.conn(), binary(), keyword()) :: term()

Get a graph. Raises on error.

See get/2.

get_edge(conn, graph, collection, edge, opts \\ [])

@spec get_edge(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Get an edge

Gets an edge from the given collection.

get_edge!(conn, graph, collection, edge, opts \\ [])

@spec get_edge!(Arangox.conn(), binary(), binary(), binary(), keyword()) :: term()

Get an edge. Raises on error.

See get_edge/4.

get_vertex(conn, graph, collection, vertex, opts \\ [])

@spec get_vertex(Arangox.conn(), binary(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Get a node

Gets a node from the given collection.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "vertex" => %{
    "_id" => string,
    "_key" => string,
    "_rev" => string
  }
}

get_vertex!(conn, graph, collection, vertex, opts \\ [])

@spec get_vertex!(Arangox.conn(), binary(), binary(), binary(), keyword()) :: term()

Get a node. Raises on error.

See get_vertex/4.

replace_edge(conn, graph, collection, edge, body, opts \\ [])

@spec replace_edge(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Replace an edge

Replaces the data of an edge in the collection.

replace_edge!(conn, graph, collection, edge, body, opts \\ [])

@spec replace_edge!(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  term()

Replace an edge. Raises on error.

See replace_edge/5.

replace_edge_definition(conn, graph, collection, body, opts \\ [])

@spec replace_edge_definition(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Replace an edge definition

Change the node collections of one specific edge definition. This modifies all occurrences of this definition in all graphs known to your database.

replace_edge_definition!(conn, graph, collection, body, opts \\ [])

@spec replace_edge_definition!(Arangox.conn(), binary(), binary(), term(), keyword()) ::
  term()

Replace an edge definition. Raises on error.

See replace_edge_definition/4.

replace_vertex(conn, graph, collection, vertex, body, opts \\ [])

@spec replace_vertex(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Replace a node

Replaces the data of a node in the collection.

replace_vertex!(conn, graph, collection, vertex, body, opts \\ [])

@spec replace_vertex!(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  term()

Replace a node. Raises on error.

See replace_vertex/5.

update_edge(conn, graph, collection, edge, body, opts \\ [])

@spec update_edge(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Update an edge

Partially modify the data of the specific edge in the collection.

update_edge!(conn, graph, collection, edge, body, opts \\ [])

@spec update_edge!(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  term()

Update an edge. Raises on error.

See update_edge/5.

update_vertex(conn, graph, collection, vertex, body, opts \\ [])

@spec update_vertex(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Update a node

Updates the data of the specific node in the collection.

update_vertex!(conn, graph, collection, vertex, body, opts \\ [])

@spec update_vertex!(Arangox.conn(), binary(), binary(), binary(), term(), keyword()) ::
  term()

Update a node. Raises on error.

See update_vertex/5.

vertex_edges(conn, collection, vertex, opts \\ [])

@spec vertex_edges(Arangox.conn(), binary(), binary(), keyword()) ::
  {:ok, term()} | {:error, Exception.t()}

Get inbound and outbound edges

Returns an array of edges starting or ending in the node identified by vertex.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "edges" => [%{
    "_from" => string,
    "_id" => string,
    "_key" => string,
    "_rev" => string,
    "_to" => string
  }],
  "error" => boolean,
  "stats" => %{
    "cacheHits" => integer,
    "cacheMisses" => integer,
    "cursorsCreated" => integer,
    "cursorsRearmed" => integer,
    "documentLookups" => integer,
    "executionTime" => float,
    "filtered" => integer,
    "httpRequests" => integer,
    "intermediateCommits" => integer,
    "peakMemoryUsage" => integer,
    "scannedFull" => integer,
    "scannedIndex" => integer,
    "searchParallelism" => integer,
    "seeks" => integer,
    "writesExecuted" => integer,
    "writesIgnored" => integer
  }
}

vertex_edges!(conn, collection, vertex, opts \\ [])

@spec vertex_edges!(Arangox.conn(), binary(), binary(), keyword()) :: term()

Get inbound and outbound edges. Raises on error.

See vertex_edges/3.