execs v0.5.0 Execs.DbClient.Client behaviour

Data manipulation is handled through clients which implement this interface. Like GenServer, however, there are some sensible defaults provided for certain callbacks so be sure to add ‘use Execs.DbClient.Client’ to the top of your module instead of using the @behaviour tag.

Those callbacks with defaults defined are explicitely called out below.

Summary

Callbacks

Create the specified number of entities and returns the ids

Delete the schema for the database

Create the tables for the database

Delete an entity and all its data

Delete a component and all its data from an entity

Delete a key from a component of an entity

Drop the tables for the database

List the entities which have a component or a set of components

List the entities which have a key or set of keys

List the entities which have certain values. This is determined by passing the value to the passed in filter function and evaluating the boolean result

List the entities which have at least one of a set of components

List the entities which have at least one of set of keys

List the entities which have at least one of a set of certain values. This is determined by passing the value to the passed in filter function and evaluating the boolean result

Check to see if one or more entities have a component or set of components

Check to see if one or more entities have a key or set of keys

Check to see if one or more entities have a value. This is determined by passing the value associated with the provided id to the passed in filter function and evaluating the boolean result

Check to see if one or more entities have a component or set of components

Check to see if one or more entities have a key or set of keys

Check to see if one or more entities have a value. This is determined by passing the value associated with the provided id to the passed in filter function and evaluating the boolean result

Check to see if one or more entities have a component or set of components

Check to see if one or more entities have a key or set of keys

Check to see if one or more entities have a value. This is determined by passing the value associated with the provided id to the passed in filter function and evaluating the boolean result

Called when Execs is starting. Provides a hook to ensure any required applications have been started and/or any setup has a chance to be performed

List the components of an entity

List the keys belonging to a component of an entity

Read an entity or set of entities

Read a component or set of component from an entity or set of entities

Read a key or set of keys from an entity or set of entities

Called when Execs is shutting down. Provides a hook to ensure any required teardown work has been performed

Take a function and execute it in the context of a transaction

Write a value to any combination of ids, components, and entities

Types

component()
component :: atom
component_list()
component_match()
component_match :: %{id: id, components: %{optional(component) => boolean}}
component_match_list()
entity()
entity :: %{id: id, components: %{optional(component) => kv_pairs}}
entity_list()
fun_list()
fun_list :: [(... -> any)]
id()
id
id_list()
id_list :: [id]
id_match()
id_match :: %{id: id, result: boolean}
id_match_list()
key()
key :: any
key_list()
key_list :: [key]
key_match()
key_match :: %{id: id, components: %{optional(component) => %{optional(key) => boolean}}}
key_match_list()
kv_pairs()
kv_pairs :: map
list_components()
list_components :: %{id: id, components: component_list}
list_components_list()
list_keys()
list_keys :: %{id: id, components: %{optional(component) => [key]}}
list_keys_list()
maybe_component_list()
maybe_entity_list()
maybe_fun_list()
maybe_fun_list :: (... -> any) | fun_list
maybe_id_list()
maybe_id_match_list()
maybe_key_list()
maybe_key_match_list()
maybe_list_keys_list()

Callbacks

create(total)
create(total :: integer) :: id_list

Create the specified number of entities and returns the ids.

create_schema()
create_schema :: any
create_schema :: any

Delete the schema for the database.

If this callback is not implemented, the default callback performs no action.

create_tables()
create_tables :: any

Create the tables for the database.

If this callback is not implemented, the default callback performs no action.

delete(maybe_id_list)

Delete an entity and all its data.

delete(maybe_id_list, maybe_component_list)

Delete a component and all its data from an entity.

delete(maybe_id_list, maybe_component_list, maybe_key_list)

Delete a key from a component of an entity.

drop_tables()
drop_tables :: any

Drop the tables for the database.

If this callback is not implemented, the default callback performs no action.

find_with_all(maybe_component_list)
find_with_all(maybe_component_list) :: id_list

List the entities which have a component or a set of components.

find_with_all(maybe_component_list, maybe_key_list)

List the entities which have a key or set of keys.

find_with_all(maybe_component_list, maybe_key_list, maybe_fun_list)

List the entities which have certain values. This is determined by passing the value to the passed in filter function and evaluating the boolean result.

A true result means that the entity which has that particular value will be included in the results.

find_with_any(maybe_component_list)
find_with_any(maybe_component_list) :: id_list

List the entities which have at least one of a set of components.

find_with_any(maybe_component_list, maybe_key_list)

List the entities which have at least one of set of keys.

find_with_any(maybe_component_list, maybe_key_list, maybe_fun_list)

List the entities which have at least one of a set of certain values. This is determined by passing the value to the passed in filter function and evaluating the boolean result.

A true result means that the entity which has that particular value will be included in the results.

has_all(maybe_id_list, maybe_component_list)

Check to see if one or more entities have a component or set of components.

has_all(maybe_id_list, maybe_component_list, maybe_key_list)

Check to see if one or more entities have a key or set of keys..

has_all(maybe_id_list, maybe_component_list, maybe_key_list, maybe_fun_list)

Check to see if one or more entities have a value. This is determined by passing the value associated with the provided id to the passed in filter function and evaluating the boolean result.

has_any(maybe_id_list, maybe_component_list)

Check to see if one or more entities have a component or set of components.

has_any(maybe_id_list, maybe_component_list, maybe_key_list)

Check to see if one or more entities have a key or set of keys.

has_any(maybe_id_list, maybe_component_list, maybe_key_list, maybe_fun_list)

Check to see if one or more entities have a value. This is determined by passing the value associated with the provided id to the passed in filter function and evaluating the boolean result.

has_which(maybe_id_list, maybe_component_list)

Check to see if one or more entities have a component or set of components.

Returns a map of the results.

has_which(maybe_id_list, maybe_component_list, maybe_key_list)

Check to see if one or more entities have a key or set of keys.

Returns a map of the results.

has_which(maybe_id_list, maybe_component_list, maybe_key_list, maybe_fun_list)

Check to see if one or more entities have a value. This is determined by passing the value associated with the provided id to the passed in filter function and evaluating the boolean result.

initialize()
initialize :: any

Called when Execs is starting. Provides a hook to ensure any required applications have been started and/or any setup has a chance to be performed.

If this callback is not implemented, the default callback performs no action.

list(maybe_id_list)

List the components of an entity.

list(maybe_id_list, maybe_component_list)

List the keys belonging to a component of an entity.

read(maybe_id_list)

Read an entity or set of entities.

read(maybe_id_list, maybe_component_list)

Read a component or set of component from an entity or set of entities.

read(maybe_id_list, maybe_component_list, maybe_key_list)

Read a key or set of keys from an entity or set of entities.

teardown(any)
teardown(any) :: any

Called when Execs is shutting down. Provides a hook to ensure any required teardown work has been performed.

If this callback is not implemented, the default callback performs no action.

transaction(list)
transaction((... -> any)) :: any

Take a function and execute it in the context of a transaction.

write(maybe_id_list, maybe_component_list, maybe_key_list, any)

Write a value to any combination of ids, components, and entities.