Module watts_persistent_mnesia

this module implement the persistent storage for the internal Erlang database called mnesia.

Behaviours: watts_persistent.

See also: watts_persistent_leveldb.

Description

this module implement the persistent storage for the internal Erlang database called mnesia. As there is an extension for mnesia that uses leveldb, this also enables support for the leveldb.

Function Index

convert_result/1*convert the result to a common return value.
create_random_uuid/0*create a random uuid for the credential.
create_tables/0*create the needed tables.
credential_add/5store a credential for a user A callback from the watts_persistent behaviour.
credential_get/1get a specific credential.
credential_get_count/2get the number of credentials for a user at a service.
credential_get_list/1get the list of credentials for a user A callback from the watts_persistent behaviour.
credential_remove/2remove a credential of a user A callback from the watts_persistent behaviour.
initialize/0initialize the sqlite database.
is_ready/0return if the database is ready.
match_spec/2*match specifications to search within the mnesia database.
setup_mnesia_if_needed/1*create the schema for the mnesia database if needed.
start_mnesia/0*start the mnesia application.
stop_mnesia/0*stop the mnesia application.

Function Details

convert_result/1 *

convert_result(X1::tuple()) -> {ok, any()} | {error, Reason::atom()}

convert the result to a common return value

create_random_uuid/0 *

create_random_uuid() -> binary()

create a random uuid for the credential

create_tables/0 *

create_tables() -> ok

create the needed tables

credential_add/5

credential_add(UserId::binary(), ServiceId::binary(), Interface::binary(), CredState::any(), AllowNonUniqueStates::boolean()) -> {ok, CredentialID::binary()} | {error, Reason::atom()}

store a credential for a user A callback from the watts_persistent behaviour.

credential_get/1

credential_get(CredId::binary()) -> {ok, watts:credential()} | {error, Reason::atom()}

get a specific credential. A callback from the watts_persistent behaviour.

credential_get_count/2

credential_get_count(UserId::binary(), ServiceId::binary()) -> {ok, pos_integer()}

get the number of credentials for a user at a service. A callback from the watts_persistent behaviour.

credential_get_list/1

credential_get_list(UserId::binary()) -> {ok, [watts:credential()]}

get the list of credentials for a user A callback from the watts_persistent behaviour.

credential_remove/2

credential_remove(UserId::binary(), CredentialId::binary()) -> ok | {error, Reason::atom()}

remove a credential of a user A callback from the watts_persistent behaviour.

initialize/0

initialize() -> ok

initialize the sqlite database. A callback from the watts_persistent behaviour.

is_ready/0

is_ready() -> true | {false, Reason::atom()}

return if the database is ready. A callback from the watts_persistent behaviour.

match_spec/2 *

match_spec(CredentialUuid::binary(), UserId::binary() | undefined) -> [tuple()]

match specifications to search within the mnesia database

setup_mnesia_if_needed/1 *

setup_mnesia_if_needed(X1::boolean()) -> ok

create the schema for the mnesia database if needed

start_mnesia/0 *

start_mnesia() -> ok

start the mnesia application

stop_mnesia/0 *

stop_mnesia() -> ok

stop the mnesia application


Generated by EDoc