View Source erldns_storage_mnesia (erldns v4.2.0)

Summary

Functions

Should backup the tables in the schema. https://github.com/SiftLogic/erl-dns/issues/3

Create the schema for mnesia, get the configuration from the config. Function sends 'ok' if schema is created, or if it already exists.

Delete a mnesia record, have to do things different for zones since we specified {record_name, zone} in the table creation.

delete the entire table.

Clear all objects from given table in mnesia DB.

Wrapper for foldl.

Insert into specified table. zone_cache calls this by {name, #zone{}}

Lists the contents of the given table.

Select based on key value.

Select using ETS match spec converted to Mnesia's match_object pattern

Delete all zone records or zone records typed based on the match spec. The match spec is given as an ETS match spec, thus it needs to be converted to a record match spec for Mnesia.

Functions

backup_table(Table)

-spec backup_table(atom()) -> ok | {error, Reason :: term()}.

Should backup the tables in the schema. https://github.com/SiftLogic/erl-dns/issues/3

backup_tables()

-spec backup_tables() -> ok | {error, Reason :: term()}.

create(_)

-spec create(atom()) -> ok.

Create the schema for mnesia, get the configuration from the config. Function sends 'ok' if schema is created, or if it already exists.

delete(Table, Key)

-spec delete(Table :: atom(), Key :: term()) -> ok | any().

Delete a mnesia record, have to do things different for zones since we specified {record_name, zone} in the table creation.

delete_table(Table)

-spec delete_table(atom()) -> ok | {aborted, any()}.

delete the entire table.

empty_table(Table)

-spec empty_table(atom()) -> ok | {aborted, term()}.

Clear all objects from given table in mnesia DB.

foldl(Iterator, Acc, Table)

-spec foldl(fun(), list(), atom()) -> Acc :: term() | {error, Reason :: term()}.

Wrapper for foldl.

insert(_, Zone)

-spec insert(atom(), any()) -> any().

Insert into specified table. zone_cache calls this by {name, #zone{}}

list_table(Name)

-spec list_table(atom()) ->
                    [] |
                    [#zone{name :: dns:dname(),
                           version :: binary(),
                           authority :: [dns:rr()],
                           record_count :: non_neg_integer(),
                           records :: [dns:rr()] | trimmed,
                           records_by_name :: #{binary() => [dns:rr()]} | trimmed,
                           records_by_type :: term(),
                           keysets :: [erldns:keyset()]}] |
                    [#authorities{owner_name :: term(),
                                  ttl :: term(),
                                  class :: term(),
                                  name_server :: term(),
                                  email_addr :: term(),
                                  serial_num :: term(),
                                  refresh :: term(),
                                  retry :: term(),
                                  expiry :: term(),
                                  nxdomain :: term()}] |
                    [tuple()] |
                    {error, doesnt_exist}.

Lists the contents of the given table.

select(Table, Key)

-spec select(Table :: atom(), Key :: term()) -> [tuple()].

Select based on key value.

select(Table, _, Limit)

-spec select(atom(), list(), infinite | integer()) -> [tuple()].

Select using ETS match spec converted to Mnesia's match_object pattern

select_delete(Table, _)

-spec select_delete(atom(), list()) -> {ok, Count :: integer()} | {error, Reason :: term()}.

Delete all zone records or zone records typed based on the match spec. The match spec is given as an ETS match spec, thus it needs to be converted to a record match spec for Mnesia.