Khepri path API.
A path is the type used by Khepri to reference nodes in the tree structure. A path describes how to reach a node from the root node.
A path, or native path, is a list of components. Components can be Erlang atoms and binaries. Example:
%% Native path.
Path = [stock, wood, oak].
A path may contain conditions to tune how a node is matched or to match
multiple nodes at once. This is called a path pattern. A path
pattern may contain conditions in addition to regular components (Erlang
atoms and binaries). See khepri_condition
to learn more about
conditions. Example:
%% Path pattern with a condition on `wood'.
PathPattern = [stock,
#if_all{conditions = [wood,
#if_node_exists{exists = true}]},
oak].
To be user-friendly, Unix-like string-based paths are accepted by most
functions. These Unix paths have the "/path/to/node"
and is the
equivalent of the [path, to, node]
native path.
%% Unix path, equivalent of the first native path example.
UnixPath = "/stock/wood/oak".
component() = node_id() | 47 | 46 | 94
Component name in a path to a node.
node_id() = atom() | binary()
A node name.
path() = [component()]
Path to a node.
pattern() = [pattern_component()]
Path pattern which may match zero, one or more nodes.
pattern_component() = component() | khepri_condition:condition()
from_string(PathString::string()) -> pattern()
component_from_string(Component::string()) -> pattern_component()
to_string(Path::path()) -> string()
component_to_string(Component::component()) -> string()
combine_with_conditions(Path::pattern(), Conditions::[khepri_condition:condition()]) -> pattern()
is_valid(PathPattern) -> IsValid
PathPattern = pattern()
IsValid = true | {false, pattern_component()}
ensure_is_valid(PathPattern) -> ok | no_return()
PathPattern = pattern()
pattern_includes_root_node(X1) -> any()
Generated by EDoc