Arangox.API.Databases (Arangox v0.8.0)

Copy Markdown View Source

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

List all databases

List all databases. Raises on error.

List the accessible databases

List the accessible databases. Raises on error.

Create a database

Create a database. Raises on error.

Get information about the current database

Get information about the current database. Raises on error.

Drop a database. Raises on error.

Functions

all(conn, opts \\ [])

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

List all databases

Retrieves the list of all existing databases

INFO: Retrieving the list of databases is only possible from within the _system database.

Returns

Recorded against ArangoDB 3.12.10:

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

all!(conn, opts \\ [])

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

List all databases. Raises on error.

See all/1.

all_user_accessible(conn, opts \\ [])

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

List the accessible databases

Retrieves the list of all databases the current user can access without specifying a different username or password.

Returns

Recorded against ArangoDB 3.12.10:

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

all_user_accessible!(conn, opts \\ [])

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

List the accessible databases. Raises on error.

See all_user_accessible/1.

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

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

Create a database

Creates a new database.

The response is a JSON object with the attribute result set to true.

INFO: Creating a new database is only possible from within the _system database.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "result" => boolean
}

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

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

Create a database. Raises on error.

See create/2.

current(conn, opts \\ [])

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

Get information about the current database

Retrieves the properties of the current database

The response is a JSON object with the following attributes:

  • name: the name of the current database
  • id: the id of the current database
  • path: the filesystem path of the current database
  • isSystem: whether or not the current database is the _system database
  • sharding: the default sharding method for collections created in this database
  • replicationFactor: the default replication factor for collections in this database
  • writeConcern: the default write concern for collections in this database

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "result" => %{
    "id" => string,
    "isSystem" => boolean,
    "name" => string,
    "path" => string
  }
}

current!(conn, opts \\ [])

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

Get information about the current database. Raises on error.

See current/1.

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

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

Drop a database

Drops the database along with all data stored in it.

INFO: Dropping a database is only possible from within the _system database. The _system database itself cannot be dropped.

Returns

Recorded against ArangoDB 3.12.10:

%{
  "code" => integer,
  "error" => boolean,
  "result" => boolean
}

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

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

Drop a database. Raises on error.

See delete/2.