Database administration.
{:ok, names} = TypeDB.Database.list(conn)
:ok = TypeDB.Database.create(conn, "social")
{:ok, schema} = TypeDB.Database.schema(conn, "social")
:ok = TypeDB.Database.delete(conn, "social")delete/2 destroys the database and everything in it, irreversibly.
Summary
Functions
Creates a database.
Creates a database, raising on failure.
Creates a database unless it already exists.
Creates a database unless it already exists, raising on failure.
Deletes a database and all of its data. This cannot be undone.
Deletes a database, raising on failure.
Returns whether a database exists.
Returns the name of a database, or {:error, %TypeDB.Error{status: 404}} if it
does not exist.
Returns a database name, raising on failure.
Lists the names of all databases the authenticated user can see.
Lists database names, raising on failure.
Returns the full schema of a database as TypeQL source: types and functions.
Returns the full schema of a database, raising on failure.
Returns only the type definitions of a database's schema, without functions.
Returns a database's type definitions, raising on failure.
Functions
@spec create(TypeDB.Connection.t(), String.t()) :: :ok | {:error, TypeDB.Error.t()}
Creates a database.
Creating a database that already exists is a no-op on TypeDB 3.x: the call
succeeds and the existing data is left untouched. create_if_not_exists/2
states that intent explicitly and also copes with a server that rejects the
duplicate.
@spec create!(TypeDB.Connection.t(), String.t()) :: :ok
Creates a database, raising on failure.
@spec create_if_not_exists(TypeDB.Connection.t(), String.t()) :: :ok | {:error, TypeDB.Error.t()}
Creates a database unless it already exists.
Two callers racing here is safe: whoever loses sees the database already
present and returns :ok.
@spec create_if_not_exists!(TypeDB.Connection.t(), String.t()) :: :ok
Creates a database unless it already exists, raising on failure.
@spec delete(TypeDB.Connection.t(), String.t()) :: :ok | {:error, TypeDB.Error.t()}
Deletes a database and all of its data. This cannot be undone.
Deleting a database that does not exist is an error (DBD1), unlike
create/2 — the asymmetry is TypeDB's, not this driver's.
@spec delete!(TypeDB.Connection.t(), String.t()) :: :ok
Deletes a database, raising on failure.
@spec exists?(TypeDB.Connection.t(), String.t()) :: boolean()
Returns whether a database exists.
Raises TypeDB.Error for anything other than a clean "not found" — an
unreachable server, a rejected token, a 500. A boolean cannot express "I could
not ask", and answering false to that question is the answer that makes a
caller do the wrong thing: unless exists?(conn, x), do: create(conn, x) would
try to create while the server is down. Use get/2 if you would rather branch
on the error yourself.
@spec get(TypeDB.Connection.t(), String.t()) :: {:ok, String.t()} | {:error, TypeDB.Error.t()}
Returns the name of a database, or {:error, %TypeDB.Error{status: 404}} if it
does not exist.
@spec get!(TypeDB.Connection.t(), String.t()) :: String.t()
Returns a database name, raising on failure.
@spec list(TypeDB.Connection.t()) :: {:ok, [String.t()]} | {:error, TypeDB.Error.t()}
Lists the names of all databases the authenticated user can see.
@spec list!(TypeDB.Connection.t()) :: [String.t()]
Lists database names, raising on failure.
@spec schema(TypeDB.Connection.t(), String.t()) :: {:ok, String.t()} | {:error, TypeDB.Error.t()}
Returns the full schema of a database as TypeQL source: types and functions.
Round-trips: feeding the result to a define query in an empty database
reproduces the schema.
@spec schema!(TypeDB.Connection.t(), String.t()) :: String.t()
Returns the full schema of a database, raising on failure.
@spec type_schema(TypeDB.Connection.t(), String.t()) :: {:ok, String.t()} | {:error, TypeDB.Error.t()}
Returns only the type definitions of a database's schema, without functions.
@spec type_schema!(TypeDB.Connection.t(), String.t()) :: String.t()
Returns a database's type definitions, raising on failure.