fdb v5.1.7-5 FDB.Directory View Source

Directory is one of the ways to manage namespaces.

root = FDB.Directory.new()
dir = FDB.Database.transact(db, fn tr ->
  FDB.Directory.create_or_open(root, tr, ["users", "inactive"])
end)
inactive_subspace = FDB.Coder.Subspace.new(dir)

Link to this section Summary

Functions

Creates a directory with given path. Parent directories are created if necessary. The method will raise an exception if the given directory already exists

Opens the directory with the given path. If the directory does not exist, it is created (creating parent directories if necessary)

Returns true if the directory at path exists and false otherwise

Gets the directory layer

Returns an list of names of the immediate subdirectories of the directory at path. Each name represents the last component of a subdirectory’s path

Moves the directory at old_path to new_path. There is no effect on the prefix of the given directory or on clients that already have the directory open. The function will raise an exception if a directory does not exist at old_path, a directory already exists at new_path, or the parent directory of new_path does not exist

Moves this directory to new_path, interpreting new_path absolutely. There is no effect on the prefix of the given directory or on clients that already have the directory open. The function will raise an exception if a directory already exists at new_path or the parent directory of new_path does not exist

Creates root directory

Opens the directory with given path. The function will raise an exception if the directory does not exist

Gets the directory path

Gets the directory prefix

Removes the directory at path, its contents, and all subdirectories. The function will raise an exception if the directory does not exist

Checks if the directory at path exists and, if so, removes the directory, its contents, and all subdirectories. Returns true if the directory existed and false otherwise

Link to this section Types

Link to this type t() View Source
t() :: FDB.Directory.Protocol.t()

Link to this section Functions

Link to this function create(directory, tr, path, options \\ %{}) View Source
create(t(), FDB.Transaction.t(), path(), map()) :: t()

Creates a directory with given path. Parent directories are created if necessary. The method will raise an exception if the given directory already exists.

Options

layer - (binary) if the layer is specified, it is recorded with the directory and will be checked by future calls to open.

prefix - (binary) if prefix is specified, the directory is created with the given prefix; otherwise a prefix is allocated automatically.

Link to this function create_or_open(directory, tr, path, options \\ %{}) View Source
create_or_open(t(), FDB.Transaction.t(), path(), map()) :: t()

Opens the directory with the given path. If the directory does not exist, it is created (creating parent directories if necessary).

Options

layer - (binary) if the layer is specified and the directory is new, it is recorded as the layer; if layer is specified and the directory already exists, it is compared against the layer specified when the directory was created, and the method will raise an exception if they differ.

Link to this function exists?(directory, tr, path \\ []) View Source
exists?(t(), FDB.Transaction.t(), path()) :: t()

Returns true if the directory at path exists and false otherwise.

Link to this function layer(directory) View Source
layer(t()) :: String.t()

Gets the directory layer

Link to this function list(directory, tr, path \\ []) View Source
list(t(), FDB.Transaction.t(), path()) :: t()

Returns an list of names of the immediate subdirectories of the directory at path. Each name represents the last component of a subdirectory’s path.

Link to this function move(directory, tr, old_path, new_path) View Source
move(t(), FDB.Transaction.t(), path(), path()) :: t()

Moves the directory at old_path to new_path. There is no effect on the prefix of the given directory or on clients that already have the directory open. The function will raise an exception if a directory does not exist at old_path, a directory already exists at new_path, or the parent directory of new_path does not exist.

Returns the directory at its new location.

Link to this function move_to(directory, tr, new_absolute_path) View Source
move_to(t(), FDB.Transaction.t(), path()) :: t()

Moves this directory to new_path, interpreting new_path absolutely. There is no effect on the prefix of the given directory or on clients that already have the directory open. The function will raise an exception if a directory already exists at new_path or the parent directory of new_path does not exist.

Returns the directory at its new location.

Link to this function new(options \\ %{}) View Source
new(map()) :: t()

Creates root directory

Options

  • node_subspace - (FDB.Coder.t/0) where the directory metadata should be stored. Defaults to Subspace.new(<<0xFE>>)
  • content_subspace - (FDB.Coder.t/0) where contents are stored. Defaults to Subspace.new("")
  • allow_manual_prefixes - (boolean) whether manual prefixes should be allowed for directories. Defaults to false
Link to this function open(directory, tr, path, options \\ %{}) View Source
open(t(), FDB.Transaction.t(), path(), map()) :: t()

Opens the directory with given path. The function will raise an exception if the directory does not exist.

Options

layer - (binary) if the layer is specified, it is compared against the layer specified when the directory was created, and the function will raise an exception if they differ.

Link to this function path(directory) View Source
path(t()) :: path()

Gets the directory path

Link to this function prefix(directory) View Source
prefix(t()) :: binary()

Gets the directory prefix

Link to this function remove(directory, tr, path \\ []) View Source
remove(t(), FDB.Transaction.t(), path()) :: t()

Removes the directory at path, its contents, and all subdirectories. The function will raise an exception if the directory does not exist.

Clients that have already opened the directory might still insert data into its contents after removal.

Link to this function remove_if_exists(directory, tr, path \\ []) View Source
remove_if_exists(t(), FDB.Transaction.t(), path()) :: t()

Checks if the directory at path exists and, if so, removes the directory, its contents, and all subdirectories. Returns true if the directory existed and false otherwise.

Clients that have already opened the directory might still insert data into its contents after removal.