Arangox.API.Import (Arangox v0.8.0)

Copy Markdown View Source

ArangoDB's Import 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

Imports documents into a collection.

Import JSON data as documents. Raises on error.

Functions

data(conn, collection, body, opts \\ [])

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

Imports documents into a collection.

The body is sent as given under text/plain, so it must already be a binary in one of the formats ArangoDB accepts. Say which one with :type:

  • type: "documents" - one JSON object per line (JSON Lines)
  • type: "list" - a single JSON array of objects
  • type: "auto" - let the server detect either of the above
  • no :type - the first line is a JSON array of attribute names, and every line after it is a JSON array of values in that same order

Importing into an edge collection requires _from and _to on every document.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "created" => integer,
  "empty" => integer,
  "error" => boolean,
  "errors" => integer,
  "ignored" => integer,
  "updated" => integer
}

data!(conn, collection, body, opts \\ [])

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

Import JSON data as documents. Raises on error.

See data/3.