Khepri database advanced API.
This module exposes variants of the functions in khepri
which
return more detailed return values for advanced use cases. Here are some
examples of what can be achieved with this module:
undefined
atom as its payload, from
a tree node with no payload, from a non-existing tree node.put/4
which can be useful to perform transactional operations without
using khepri:transaction/4
.khepri
are implemented on top of this module
and simplify the return value for the more common use cases.
many_results() = khepri_machine:common_ret()
Return value of a query or synchronous command targeting many tree nodes.
node_props_map() = #{khepri_path:native_path() => khepri:node_props()}
Structure used to return a map of nodes and their associated properties, payload and child nodes.
single_result() = khepri:ok(khepri:node_props() | #{}) | khepri:error()
Return value of a query or synchronous command targeting one specific tree node.
get/1 | Returns the properties and payload of the tree node pointed to by the given path pattern. |
get/2 | Returns the properties and payload of the tree node pointed to by the given path pattern. |
get/3 | Returns the properties and payload of the tree node pointed to by the given path pattern. |
get_many/1 | Returns properties and payloads of all the tree nodes matching the given path pattern. |
get_many/2 | Returns properties and payloads of all the tree nodes matching the given path pattern. |
get_many/3 | Returns properties and payloads of all the tree nodes matching the given path pattern. |
put/2 | Sets the payload of the tree node pointed to by the given path pattern. |
put/3 | Sets the payload of the tree node pointed to by the given path pattern. |
put/4 | Sets the payload of the tree node pointed to by the given path pattern. |
put_many/2 | Sets the payload of all the tree nodes matching the given path pattern. |
put_many/3 | Sets the payload of all the tree nodes matching the given path pattern. |
put_many/4 | Sets the payload of all the tree nodes matching the given path pattern. |
create/2 | Creates a tree node with the given payload. |
create/3 | Creates a tree node with the given payload. |
create/4 | Creates a tree node with the given payload. |
update/2 | Updates an existing tree node with the given payload. |
update/3 | Updates an existing tree node with the given payload. |
update/4 | Updates an existing tree node with the given payload. |
compare_and_swap/3 | Updates an existing tree node with the given payload only if its data matches the given pattern. |
compare_and_swap/4 | Updates an existing tree node with the given payload only if its data matches the given pattern. |
compare_and_swap/5 | Updates an existing tree node with the given payload only if its data matches the given pattern. |
delete/1 | Deletes the tree node pointed to by the given path pattern. |
delete/2 | Deletes the tree node pointed to by the given path pattern. |
delete/3 | Deletes the tree node pointed to by the given path pattern. |
delete_many/1 | Deletes all tree nodes matching the given path pattern. |
delete_many/2 | Deletes all tree nodes matching the given path pattern. |
delete_many/3 | Deletes all tree nodes matching the given path pattern. |
clear_payload/1 | Deletes the payload of the tree node pointed to by the given path pattern. |
clear_payload/2 | Deletes the payload of the tree node pointed to by the given path pattern. |
clear_payload/3 | Deletes the payload of the tree node pointed to by the given path pattern. |
clear_many_payloads/1 | Deletes the payload of all tree nodes matching the given path pattern. |
clear_many_payloads/2 | Deletes the payload of all tree nodes matching the given path pattern. |
clear_many_payloads/3 | Deletes the payload of all tree nodes matching the given path pattern. |
unregister_projections/1 | Removes the given projections from the store. |
unregister_projections/2 | Removes the given projections from the store. |
unregister_projections/3 | Removes the given projections from the store. |
get(PathPattern) -> Ret
PathPattern = khepri_path:pattern()
Ret = khepri_adv:single_result()
Returns the properties and payload of the tree node pointed to by the given path pattern.
Calling this function is the same as callingget(StoreId, PathPattern)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
get(StoreId, PathPattern) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Ret = khepri_adv:single_result()
get(PathPattern, Options) -> Ret
PathPattern = khepri_path:pattern()
Options = khepri:query_options() | khepri:tree_options()
Ret = khepri_adv:single_result()
Returns the properties and payload of the tree node pointed to by the given path pattern.
This function accepts the following two forms:get(StoreId, PathPattern)
. Calling it is the same as calling
get(StoreId, PathPattern, #{})
.get(PathPattern, Options)
. Calling it is the same as calling
get(StoreId, PathPattern, Options)
with the default store ID (see khepri_cluster:get_default_store_id/0
).See also: get/3.
get(StoreId, PathPattern, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Options = khepri:query_options() | khepri:tree_options()
Ret = khepri_adv:single_result()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree node to get.
Options
: query options.
returns: an {ok, NodeProps}
tuple or an {error, Reason}
tuple.
Returns the properties and payload of the tree node pointed to by the given path pattern.
The PathPattern
can be provided as a native path pattern (a list of tree
node names and conditions) or as a string. See khepri_path:from_string/1
.
The PathPattern
must target a specific tree node. In other words,
updating many nodes with the same payload is denied. That fact is checked
before the tree node is looked up: so if a condition in the path could
potentially match several nodes, an exception is raised, even though only
one tree node would match at the time. If you want to get multiple nodes at
once, use get_many/3
.
The returned {ok, NodeProps}
tuple contains a map with the properties and
payload (if any) of the targeted tree node. If the tree node is not found,
{error, ?khepri_error(node_not_found, Info)}
is returned.
value
%% Query the tree node at `/:foo/:bar'.
{ok, #{data := value,
payload_version := 1}} = khepri_adv:get(StoreId, [foo, bar]).
Example: query an existing tree node with no payload
%% Query the tree node at `/:no_payload'.
{ok, #{payload_version := 1}} = khepri_adv:get(StoreId, [no_payload]).
Example: query a non-existent tree node
%% Query the tree node at `/:non_existent'.
{error, ?khepri_error(node_not_found, _)} = khepri_adv:get(
StoreId, [non_existent]).
See also: get_many/3, khepri:get/3.
get_many(PathPattern) -> Ret
PathPattern = khepri_path:pattern()
Ret = khepri_adv:many_results()
Returns properties and payloads of all the tree nodes matching the given path pattern.
Calling this function is the same as callingget_many(StoreId,
PathPattern)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
See also: get_many/2, get_many/3.
get_many(StoreId, PathPattern) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Ret = khepri_adv:many_results()
get_many(PathPattern, Options) -> Ret
PathPattern = khepri_path:pattern()
Options = khepri:query_options() | khepri:tree_options()
Ret = khepri_adv:many_results()
Returns properties and payloads of all the tree nodes matching the given path pattern.
This function accepts the following two forms:get_many(StoreId, PathPattern)
. Calling it is the same as calling
get_many(StoreId, PathPattern, #{})
.get_many(PathPattern, Options)
. Calling it is the same as calling
get_many(StoreId, PathPattern, Options)
with the default store ID (see
khepri_cluster:get_default_store_id/0
).See also: get_many/3.
get_many(StoreId, PathPattern, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Options = khepri:query_options() | khepri:tree_options()
Ret = khepri_adv:many_results()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree nodes to get.
Options
: query options such as favor
.
returns: an {ok, NodePropsMap}
tuple or an {error, Reason}
tuple.
Returns properties and payloads of all the tree nodes matching the given path pattern.
The PathPattern
can be provided as a native path pattern (a list of tree
node names and conditions) or as a string. See khepri_path:from_string/1
.
The returned {ok, NodePropsMap}
tuple contains a map where keys correspond
to the path to a tree node matching the path pattern. Each key then points
to a map containing the properties and payload (if any) of that matching
tree node.
%% Get all nodes in the tree. The tree is:
%% <root>
%% `-- foo
%% `-- bar = value
{ok, #{[foo] :=
#{payload_version := 1},
[foo, bar] :=
#{data := value,
payload_version := 1}}} = khepri_adv:get_many(
StoreId,
[?KHEPRI_WILDCARD_STAR_STAR]).
See also: get/3, khepri:get_many/3.
put(PathPattern, Data) -> Ret
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri:minimal_ret() | khepri_adv:single_result()
Sets the payload of the tree node pointed to by the given path pattern.
Calling this function is the same as callingput(StoreId, PathPattern,
Data)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
put(StoreId, PathPattern, Data) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri:minimal_ret() | khepri_adv:single_result()
Sets the payload of the tree node pointed to by the given path pattern.
Calling this function is the same as callingput(StoreId, PathPattern,
Data, #{})
.
See also: put/4.
put(StoreId, PathPattern, Data, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Options = khepri:command_options() | khepri:tree_options() | khepri:put_options()
Ret = khepri:minimal_ret() | khepri_adv:single_result() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree node to create or
modify.
Data
: the Erlang term or function to store, or a khepri_payload:payload()
structure.
Options
: command options.
returns: in the case of a synchronous call, an {ok, NodeProps}
tuple or
an {error, Reason}
tuple; in the case of an asynchronous call, always
ok
(the actual return value may be sent by a message if a correlation ID
was specified).
Sets the payload of the tree node pointed to by the given path pattern.
The PathPattern
can be provided as a native path pattern (a list of tree
node names and conditions) or as a string. See khepri_path:from_string/1
.
The PathPattern
must target a specific tree node. In other words,
updating many nodes with the same payload is denied. That fact is checked
before the tree node is looked up: so if a condition in the path could
potentially match several nodes, an exception is raised, even though only
one tree node would match at the time.
When using a simple path (i.e. without conditions), if the targeted tree node does not exist, it is created using the given payload. If the targeted tree node exists, it is updated with the given payload and its payload version is increased by one. Missing parent nodes are created on the way.
When using a path pattern, the behavior is the same. However if a condition in the path pattern is not met, an error is returned and the tree structure is not modified.
The returned {ok, NodeProps}
tuple contains a map with the properties and
payload (if any) of the targeted tree node: the payload was the one before
the update, other properties like the payload version correspond to the
updated node. If the targeted tree node didn't exist, NodeProps
will be
an empty map.
khepri_payload:no_payload()
),
using the marker returned by khepri_payload:none/0
, meaning there
will be no payload attached to the tree node and the existing payload will
be discarded if anykhepri_payload:sproc()
recordkhepri_payload:data()
recordIt is possible to wrap the payload in its internal structure explicitly
using the khepri_payload
module directly.
The Options
map may specify command-level options; see khepri:command_options()
, khepri:tree_options()
and khepri:put_options()
.
When doing an asynchronous update, the handle_async_ret/1
function should be used to handle the message received from Ra.
The returned {ok, NodeProps}
tuple contains a map with the properties and
payload (if any) of the targeted tree node as they were before the put.
%% Insert a tree node at `/:foo/:bar', overwriting the previous value.
{ok, #{data := value,
payload_version := 1}} = khepri_adv:put(
StoreId, [foo, bar], new_value).
See also: compare_and_swap/5, create/4, update/4, khepri:put/4.
put_many(PathPattern, Data) -> Ret
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri_adv:many_results()
Sets the payload of all the tree nodes matching the given path pattern.
Calling this function is the same as callingput_many(StoreId, PathPattern,
Data)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
See also: put_many/3, put_many/4.
put_many(StoreId, PathPattern, Data) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri_adv:many_results()
Sets the payload of all the tree nodes matching the given path pattern.
Calling this function is the same as callingput_many(StoreId, PathPattern,
Data, #{})
.
See also: put_many/4.
put_many(StoreId, PathPattern, Data, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Options = khepri:command_options() | khepri:tree_options() | khepri:put_options()
Ret = khepri_adv:many_results() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree node to create or
modify.
Data
: the Erlang term or function to store, or a khepri_payload:payload()
structure.
Options
: command options.
returns: in the case of a synchronous call, an {ok, NodePropsMap}
tuple or
an {error, Reason}
tuple; in the case of an asynchronous call, always ok
(the actual return value may be sent by a message if a correlation ID was
specified).
Sets the payload of all the tree nodes matching the given path pattern.
The PathPattern
can be provided as a native path pattern (a list of tree
node names and conditions) or as a string. See khepri_path:from_string/1
.
When using a simple path (i.e. without conditions), if the targeted tree node does not exist, it is created using the given payload. If the targeted tree node exists, it is updated with the given payload and its payload version is increased by one. Missing parent nodes are created on the way.
When using a path pattern, the behavior is the same. However if a condition in the path pattern is not met, an error is returned and the tree structure is not modified.
The returned {ok, NodePropsMap}
tuple contains a map where keys
correspond to the path to a tree node matching the path pattern. Each key
then points to a map containing the properties and payload (if any) of the
targeted tree node: the payload was the one before the update, other
properties like the payload version correspond to the updated node.
khepri_payload:no_payload()
),
using the marker returned by khepri_payload:none/0
, meaning there
will be no payload attached to the tree node and the existing payload will
be discarded if anykhepri_payload:sproc()
recordkhepri_payload:data()
recordIt is possible to wrap the payload in its internal structure explicitly
using the khepri_payload
module directly.
The Options
map may specify command-level options; see khepri:command_options()
, khepri:tree_options()
and khepri:put_options()
.
When doing an asynchronous update, the handle_async_ret/1
function should be used to handle the message received from Ra.
%% Set value of all tree nodes matching `/*/:bar', to `new_value'.
{ok, #{[foo, bar] :=
#{data := value,
payload_version := 1},
[baz, bar] :=
#{payload_version := 1}}} = khepri_adv:put_many(
StoreId,
[?KHEPRI_WILDCARD_STAR, bar],
new_value).
See also: put/4, khepri:put_many/4.
create(PathPattern, Data) -> Ret
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri_adv:single_result()
Creates a tree node with the given payload.
Calling this function is the same as callingcreate(StoreId, PathPattern,
Data)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
create(StoreId, PathPattern, Data) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri_adv:single_result()
Creates a tree node with the given payload.
Calling this function is the same as callingcreate(StoreId, PathPattern,
Data, #{})
.
See also: create/4.
create(StoreId, PathPattern, Data, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Options = khepri:command_options() | khepri:tree_options() | khepri:put_options()
Ret = khepri_adv:single_result() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree node to create.
Data
: the Erlang term or function to store, or a khepri_payload:payload()
structure.
Options
: command options.
returns: in the case of a synchronous call, an {ok, NodeProps}
tuple or
an {error, Reason}
tuple; in the case of an asynchronous call, always
ok
(the actual return value may be sent by a message if a correlation ID
was specified).
Creates a tree node with the given payload.
The behavior is the same as put/4
except that if the tree node
already exists, an {error, ?khepri_error(mismatching_node, Info)}
tuple
is returned.
PathPattern
is modified to include an
#if_node_exists{exists = false}
condition on its last component.
See also: put/4, update/4, khepri:create/4.
update(PathPattern, Data) -> Ret
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri_adv:single_result()
Updates an existing tree node with the given payload.
Calling this function is the same as callingupdate(StoreId, PathPattern,
Data)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
update(StoreId, PathPattern, Data) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri_adv:single_result()
Updates an existing tree node with the given payload.
Calling this function is the same as callingupdate(StoreId, PathPattern,
Data, #{})
.
See also: update/4.
update(StoreId, PathPattern, Data, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Options = khepri:command_options() | khepri:tree_options() | khepri:put_options()
Ret = khepri_adv:single_result() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree node to modify.
Data
: the Erlang term or function to store, or a khepri_payload:payload()
structure.
Options
: command options.
returns: in the case of a synchronous call, an {ok, NodeProps}
tuple or
an {error, Reason}
tuple; in the case of an asynchronous call, always
ok
(the actual return value may be sent by a message if a correlation ID
was specified).
Updates an existing tree node with the given payload.
The behavior is the same as put/4
except that if the tree node
already exists, an {error, ?khepri_error(mismatching_node, Info)}
tuple
is returned.
PathPattern
is modified to include an
#if_node_exists{exists = true}
condition on its last component.
See also: create/4, put/4, khepri:update/4.
compare_and_swap(PathPattern, DataPattern, Data) -> Ret
PathPattern = khepri_path:pattern()
DataPattern = ets:match_pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri_adv:single_result()
Updates an existing tree node with the given payload only if its data matches the given pattern.
Calling this function is the same as callingcompare_and_swap(StoreId,
PathPattern, DataPattern, Data)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
See also: compare_and_swap/4, compare_and_swap/5.
compare_and_swap(StoreId, PathPattern, DataPattern, Data) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
DataPattern = ets:match_pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Ret = khepri_adv:single_result()
Updates an existing tree node with the given payload only if its data matches the given pattern.
Calling this function is the same as callingcompare_and_swap(StoreId,
PathPattern, DataPattern, Data, #{})
.
See also: compare_and_swap/5.
compare_and_swap(StoreId, PathPattern, DataPattern, Data, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
DataPattern = ets:match_pattern()
Data = khepri_payload:payload() | khepri:data() | function()
Options = khepri:command_options() | khepri:tree_options() | khepri:put_options()
Ret = khepri_adv:single_result() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree node to modify.
Data
: the Erlang term or function to store, or a khepri_payload:payload()
structure.
Options
: command options.
returns: in the case of a synchronous call, an {ok, NodeProps}
tuple or
an {error, Reason}
tuple; in the case of an asynchronous call, always
ok
(the actual return value may be sent by a message if a correlation ID
was specified).
Updates an existing tree node with the given payload only if its data matches the given pattern.
The behavior is the same as put/4
except that if the tree node
already exists, an {error, ?khepri_error(mismatching_node, Info)}
tuple
is returned.
PathPattern
is modified to include an
#if_data_matches{pattern = DataPattern}
condition on its last component.
See also: put/4, khepri:compare_and_swap/5.
delete(PathPattern) -> Ret
PathPattern = khepri_path:pattern()
Ret = khepri_adv:single_result()
Deletes the tree node pointed to by the given path pattern.
Calling this function is the same as callingdelete(StoreId, PathPattern)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
delete(StoreId, PathPattern) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Ret = khepri_adv:single_result()
delete(PathPattern, Options) -> Ret
PathPattern = khepri_path:pattern()
Options = khepri:command_options() | khepri:tree_options()
Ret = khepri_adv:single_result()
Deletes the tree node pointed to by the given path pattern.
This function accepts the following two forms:delete(StoreId, PathPattern)
. Calling it is the same as calling
delete(StoreId, PathPattern, #{})
.delete(PathPattern, Options)
. Calling it is the same as calling
delete(StoreId, PathPattern, Options)
with the default store ID (see
khepri_cluster:get_default_store_id/0
).See also: delete/3.
delete(StoreId, PathPattern, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Options = khepri:command_options() | khepri:tree_options()
Ret = khepri_adv:single_result() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the nodes to delete.
Options
: command options such as the command type.
returns: in the case of a synchronous call, an {ok, NodeProps}
tuple or
an {error, Reason}
tuple; in the case of an asynchronous call, always
ok
(the actual return value may be sent by a message if a correlation ID
was specified).
Deletes the tree node pointed to by the given path pattern.
The PathPattern
can be provided as a native path pattern (a list of tree
node names and conditions) or as a string. See khepri_path:from_string/1
.
The PathPattern
must target a specific tree node. In other words,
updating many nodes with the same payload is denied. That fact is checked
before the tree node is looked up: so if a condition in the path could
potentially match several nodes, an exception is raised, even though only
one tree node would match at the time. If you want to delete multiple nodes
at once, use delete_many/3
.
The returned {ok, NodeProps}
tuple contains a map with the properties and
payload (if any) of the targeted tree node as they were before the delete.
If the targeted tree node didn't exist, NodeProps
will be an empty map.
When doing an asynchronous update, the handle_async_ret/1
function should be used to handle the message received from Ra.
%% Delete the tree node at `/:foo/:bar'.
{ok, #{data := value,
payload_version := 1}} = khepri_adv:delete(StoreId, [foo, bar]).
See also: delete_many/3, khepri:delete/3.
delete_many(PathPattern) -> Ret
PathPattern = khepri_path:pattern()
Ret = khepri_adv:many_results()
Deletes all tree nodes matching the given path pattern.
Calling this function is the same as callingdelete_many(StoreId,
PathPattern)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
See also: delete_many/2, delete_many/3.
delete_many(StoreId, PathPattern) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Ret = khepri_adv:many_results()
delete_many(PathPattern, Options) -> Ret
PathPattern = khepri_path:pattern()
Options = khepri:command_options() | khepri:tree_options()
Ret = khepri_adv:many_results()
Deletes all tree nodes matching the given path pattern.
This function accepts the following two forms:delete_many(StoreId, PathPattern)
. Calling it is the same as calling
delete(StoreId, PathPattern, #{})
.delete_many(PathPattern, Options)
. Calling it is the same as calling
delete(StoreId, PathPattern, Options)
with the default store ID (see
khepri_cluster:get_default_store_id/0
).See also: delete_many/3.
delete_many(StoreId, PathPattern, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Options = khepri:command_options() | khepri:tree_options()
Ret = khepri_adv:many_results() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the nodes to delete.
Options
: command options such as the command type.
returns: in the case of a synchronous call, an {ok, NodePropsMap}
tuple
or an {error, Reason}
tuple; in the case of an asynchronous call, always
ok
(the actual return value may be sent by a message if a correlation ID
was specified).
Deletes all tree nodes matching the given path pattern.
The PathPattern
can be provided as a native path pattern (a list of tree
node names and conditions) or as a string. See khepri_path:from_string/1
.
The returned {ok, NodePropsMap}
tuple contains a map where keys
correspond to the path to a deleted tree node. Each key then points to a
map containing the properties and payload (if any) of that deleted tree
node as they were before the delete.
When doing an asynchronous update, the handle_async_ret/1
function should be used to handle the message received from Ra.
%% Delete the tree node at `/:foo/:bar'.
{ok, #{[foo, bar] := #{data := value,
payload_version := 1},
[baz, bar] := #{payload_version := 1}}} = khepri_adv:delete_many(
StoreId, [foo, bar]).
See also: delete/3, khepri:delete/3.
clear_payload(PathPattern) -> Ret
PathPattern = khepri_path:pattern()
Ret = khepri_adv:single_result()
Deletes the payload of the tree node pointed to by the given path pattern.
Calling this function is the same as callingclear_payload(StoreId,
PathPattern)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
See also: clear_payload/2, clear_payload/3.
clear_payload(StoreId, PathPattern) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Ret = khepri_adv:single_result()
Deletes the payload of the tree node pointed to by the given path pattern.
Calling this function is the same as callingclear_payload(StoreId,
PathPattern, #{})
.
See also: clear_payload/3.
clear_payload(StoreId, PathPattern, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Options = khepri:command_options() | khepri:tree_options() | khepri:put_options()
Ret = khepri_adv:single_result() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree node to modify.
Options
: command options.
returns: in the case of a synchronous call, an {ok, NodeProps}
tuple or
an {error, Reason}
tuple; in the case of an asynchronous call, always
ok
(the actual return value may be sent by a message if a correlation ID
was specified).
Deletes the payload of the tree node pointed to by the given path pattern.
In other words, the payload is set tokhepri_payload:no_payload()
.
Otherwise, the behavior is that of update/4
.
See also: update/4, khepri:clear_payload/3.
clear_many_payloads(PathPattern) -> Ret
PathPattern = khepri_path:pattern()
Ret = khepri_adv:many_results()
Deletes the payload of all tree nodes matching the given path pattern.
Calling this function is the same as callingclear_many_payloads(StoreId,
PathPattern)
with the default store ID (see khepri_cluster:get_default_store_id/0
).
See also: clear_many_payloads/2, clear_many_payloads/3.
clear_many_payloads(StoreId, PathPattern) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Ret = khepri_adv:many_results()
Deletes the payload of all tree nodes matching the given path pattern.
Calling this function is the same as callingclear_many_payloads(StoreId,
PathPattern, #{})
.
See also: clear_many_payloads/3.
clear_many_payloads(StoreId, PathPattern, Options) -> Ret
StoreId = khepri:store_id()
PathPattern = khepri_path:pattern()
Options = khepri:command_options() | khepri:tree_options() | khepri:put_options()
Ret = khepri_adv:many_results() | khepri_machine:async_ret()
StoreId
: the name of the Khepri store.
PathPattern
: the path (or path pattern) to the tree nodes to modify.
Options
: command options.
returns: in the case of a synchronous call, an {ok, NodePropsMap}
tuple
or an {error, Reason}
tuple; in the case of an asynchronous call, always
ok
(the actual return value may be sent by a message if a correlation ID
was specified).
Deletes the payload of all tree nodes matching the given path pattern.
In other words, the payload is set tokhepri_payload:no_payload()
.
Otherwise, the behavior is that of put/4
.
See also: delete_many/3, put/4, khepri:clear_many_payloads/3.
unregister_projections(Names) -> Ret
Names = all | [khepri_projection:name()]
Ret = khepri:ok(khepri_machine:projection_map()) | khepri:error()
Removes the given projections from the store.
Calling this function is the same as callingunregister_projections(StoreId, Names)
with the default store ID (see
khepri_cluster:get_default_store_id/0
).
See also: unregister_projections/2.
unregister_projections(StoreId, Names) -> Ret
StoreId = khepri:store_id()
Names = all | [khepri_projection:name()]
Ret = khepri:ok(khepri_machine:projection_map()) | khepri:error()
unregister_projections(Names, Options) -> Ret
Names = all | [khepri_projection:name()]
Options = khepri:command_options()
Ret = khepri:ok(khepri_machine:projection_map()) | khepri:error()
Removes the given projections from the store.
This function accepts the following two forms:unregister_projections(StoreId, Names)
. Calling it is the same as
calling unregister_projections(StoreId, Names, #{})
.unregister_projections(Names, Options)
. Calling it is the same as
calling unregister_projections(StoreId, Names, Options)
with the default
store ID (see khepri_cluster:get_default_store_id/0
).See also: unregister_projections/3.
unregister_projections(StoreId, Names, Options) -> Ret
StoreId = khepri:store_id()
Names = all | [khepri_projection:name()]
Options = khepri:command_options()
Ret = khepri:ok(khepri_machine:projection_map()) | khepri:error()
StoreId
: the name of the Khepri store.
Names
: the names of projections to unregister or the atom all
to
remove all projections.
Options
: command options for unregistering the projections.
returns: ok
if the projections were unregistered, an {error, Reason}
tuple otherwise.
Removes the given projections from the store.
Names
may either be a list of projection names to remove or the atom
all
. When all
is passed, every projection in the store is removed.
Generated by EDoc