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 section Functions
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.
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.
exists?(t(), FDB.Transaction.t(), path()) :: t()
Returns true
if the directory at path exists and false
otherwise.
Gets the directory layer
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.
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.
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.
Creates root directory
Options
- node_subspace - (
FDB.Coder.t/0
) where the directory metadata should be stored. Defaults toSubspace.new(<<0xFE>>)
- content_subspace - (
FDB.Coder.t/0
) where contents are stored. Defaults toSubspace.new("")
- allow_manual_prefixes - (boolean) whether manual prefixes should be allowed for directories. Defaults to
false
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.
Gets the directory path
Gets the directory prefix
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.
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.