amnesia v0.2.8 Amnesia.Table

Link to this section Summary

Functions

Add a copy of the table to the given node with the given mode, see mnesia:add_table_copy.

Add an index to the given table for the given attribute, see mnesia:add_table_index.

Read a slot from the given table, see mnesia:dirty_slot.

Check if the given table is a bag.

Clear the given table, see mnesia:clear_table.

Change the copying mode of the given table on the given node, see mnesia:change_table_copy_type.

Get the number of records in the given table.

Create a table with the given name and definition, see mnesia:create_table.

Create a table with the given name and definition, see mnesia:create_table, raises in case of error.

Delete the given record in the given table, see mnesia:delete.

Delete the given record in the given table, see mnesia:dirty_delete.

Delete a copy of the table on the given node, see mnesia:del_table_copy.

Delete an index on the given table for the given attribute, see mnesia:del_table_index.

Destroy the given table, see mnesia:delete_table.

Destroy the given table, see mnesia:delete_table, raising in case of error.

Checks if a table exists or not.

Get the first key in the table, see mnesia:first.

Get the first key in the table, see mnesia:dirty_read.

Fold the whole given table from the left, see mnesia:foldl.

Fold the whole given table from the right, see mnesia:foldr.

Force the loading of the given table, see mnesia:force_load_table.

Get information about a given table, see mnesia:table_info.

Read all keys in the given table, see mnesia:all_keys.

Read all keys in the given table, see mnesia:dirty_all_keys.

Get the last key in the table, see mnesia:last.

Get the last key in the table, see mnesia:dirty_last.

Lock the given table for the given kind of lock, see mnesia:lock.

Change the given table majority, see mnesia:change_table_majority.

Set master nodes for the given table, see mnesia:set_master_nodes.

Select records in the given table using simple don't care values, see mnesia:match_object.

Select records in the given table using simple don't care values, see mnesia:dirty_match_object.

Check if the key is present in the given table.

Change the access mode of the given table, see mnesia:change_table_access_mode.

Move the copy of the given table from the given node to another given node, see mnesia:move_table_copy.

Get the next key in the table starting from the given key, see mnesia:next.

Get the next key in the table starting from the given key, see mnesia:dirty_next.

Check if the given table is an ordered set.

Get the previous key in the table starting from the given key, see mnesia:prev.

Get the previous key in the table starting from the given key, see mnesia:dirty_prev.

Change the given table loading priority.

Return properties of the given table.

Read records from the given table with the given key, locking in the given mode, see mnesia:read.

Read records from the given table with the given key, see mnesia:dirty_read.

Read records on the given table based on a secondary index given as position, see mnesia:index_read.

Read records on the given table based on a secondary index given as position, see mnesia:dirty_index_read.

Select records in the given table using a match_spec, see mnesia:select.

Select records in the given table using a match_spec passing a limit or a lock kind, see mnesia:select.

Select records in the given table using a match_spec passing a limit and a lock kind, see mnesia:select.

Select records in the given table using a match_spec, see mnesia:dirty_select.

Check if the given table is a set.

Transform a table, useful to change tables in a running instance, see mnesia:transform_table.

Transform a table, useful to change tables in a running instance, see mnesia:transform_table.

Transform a table, renaming it, useful to change tables in a running instance, see mnesia:transform_table.

Return the type of the given table.

Wait for the passed tables for the given timeout, see mnesia:wait_for_tables.

Write the given record in the given table, using the given lock, see mnesia:write.

Write the given record in the given table, see mnesia:dirty_write.

Link to this section Types

Link to this type

c()

c() :: [{cv(), [node()]}]
Link to this type

cv()

cv() :: :disk | :disk! | :memory
Link to this type

o()

o() :: :ok | {:error, any()}

Link to this section Functions

Link to this function

add_copy(name, node, type \\ :disk)

add_copy(atom(), node(), cv()) :: o()

Add a copy of the table to the given node with the given mode, see mnesia:add_table_copy.

  • :disk sets :disc_copies mode
  • :disk! sets :disc_only_copies mode
  • :memory sets :ram_copies mode
Link to this function

add_index(name, attribute)

add_index(atom(), atom()) :: o()

Add an index to the given table for the given attribute, see mnesia:add_table_index.

Link to this function

at!(name, position)

at!(atom(), integer()) :: tuple() | nil | no_return()

Read a slot from the given table, see mnesia:dirty_slot.

Link to this function

bag?(name)

bag?(atom()) :: boolean()

Check if the given table is a bag.

Link to this function

clear(name)

clear(atom()) :: o()

Clear the given table, see mnesia:clear_table.

Link to this function

copying(name, node, to)

copying(atom(), node(), cv()) :: o()

Change the copying mode of the given table on the given node, see mnesia:change_table_copy_type.

Modes

  • :disk sets :disc_copies mode
  • :disk! sets :disc_only_copies mode
  • :memory sets :ram_copies mode
Link to this function

count(name)

count(atom()) :: non_neg_integer()

Get the number of records in the given table.

Link to this function

create(name, definition \\ [])

create(atom(), c()) :: o()

Create a table with the given name and definition, see mnesia:create_table.

The definition is a keyword list of options which have a correspondence with mnesia options, to know what they do check the mnesia documentation.

  • :record => :record_name

  • :attributes

  • :mode => :access_mode

    • :both => :read_write
    • :read! => :read_only
  • :type

  • :index

  • :majority

  • :priority => :load_order

  • :user => :user_properties

  • :local => :local_content

  • :copying (a keyword list composed of)

    • :memory => :ram_copies
    • :disk => :disc_copies
    • :disk! => :disc_only_copies
  • :fragmentation => :frag_properties (a keyword list composed of)

    • :number => :n_fragments

    • :nodes => :node_pool

    • :foreign => :foreign_key

    • :hash (a keyword list composed of)

      • :module => :hash_module
      • :state => :hash_state
    • :copying (a keyword list composed of)

      • :memory => :n_ram_copies
      • :disk => :n_disc_copies
      • :disk! => :n_disc_only_copies
Link to this function

create!(name, definition \\ [])

create!(atom(), c()) :: :ok | no_return()

Create a table with the given name and definition, see mnesia:create_table, raises in case of error.

Link to this function

delete(name, key, lock \\ :write)

delete(atom(), any(), :write | :write!) :: :ok | no_return()

Delete the given record in the given table, see mnesia:delete.

Locks

  • :write sets a :write lock
  • :write! sets a :sticky_write lock
Link to this function

delete!(name, key)

delete!(atom(), any()) :: :ok | no_return()

Delete the given record in the given table, see mnesia:dirty_delete.

Link to this function

delete_copy(name, node)

delete_copy(atom(), node()) :: o()

Delete a copy of the table on the given node, see mnesia:del_table_copy.

Link to this function

delete_index(name, attribute)

delete_index(atom(), atom()) :: o()

Delete an index on the given table for the given attribute, see mnesia:del_table_index.

Link to this function

destroy(name)

destroy(atom()) :: o()

Destroy the given table, see mnesia:delete_table.

Link to this function

destroy!(name)

destroy!(atom()) :: :ok | no_return()

Destroy the given table, see mnesia:delete_table, raising in case of error.

Link to this function

exists?(name)

exists?(atom()) :: boolean()

Checks if a table exists or not.

Link to this function

first(name)

first(atom()) :: any() | nil | no_return()

Get the first key in the table, see mnesia:first.

Link to this function

first!(name)

first!(atom()) :: any() | nil | no_return()

Get the first key in the table, see mnesia:dirty_read.

Link to this function

foldl(name, acc, fun)

foldl(atom(), any(), (tuple(), any() -> any())) :: any() | no_return()
foldl(atom(), any(), (tuple(), any() -> any())) :: any() | no_return()

Fold the whole given table from the left, see mnesia:foldl.

Link to this function

foldr(name, acc, fun)

Fold the whole given table from the right, see mnesia:foldr.

Link to this function

force(name)

force(atom()) :: :yes | {:error, any()}

Force the loading of the given table, see mnesia:force_load_table.

Link to this function

info(name, key)

info(atom(), atom()) :: any()

Get information about a given table, see mnesia:table_info.

Link to this function

keys(name)

keys(atom()) :: list() | no_return()

Read all keys in the given table, see mnesia:all_keys.

Link to this function

keys!(name)

keys!(atom()) :: list() | no_return()

Read all keys in the given table, see mnesia:dirty_all_keys.

Link to this function

last(name)

last(atom()) :: any() | nil | no_return()

Get the last key in the table, see mnesia:last.

Link to this function

last!(name)

last!(atom()) :: any() | nil | no_return()

Get the last key in the table, see mnesia:dirty_last.

Link to this function

lock(name, mode)

lock(atom(), :write | :write! | :read) :: [node()] | :ok | no_return()

Lock the given table for the given kind of lock, see mnesia:lock.

Locks

  • :write sets a :write lock
  • :write! sets a :sticky_write lock
  • :read sets a :read lock
Link to this function

majority(name, value)

majority(atom(), boolean()) :: o()

Change the given table majority, see mnesia:change_table_majority.

Link to this function

master_nodes(name, nodes)

master_nodes(atom(), [node()]) :: :ok | {:error, any()}

Set master nodes for the given table, see mnesia:set_master_nodes.

Link to this function

match(name, lock \\ :read, pattern)

match(atom(), :read | :write, any()) :: [tuple()] | nil | no_return()

Select records in the given table using simple don't care values, see mnesia:match_object.

Link to this function

match!(name, pattern)

Select records in the given table using simple don't care values, see mnesia:dirty_match_object.

Link to this function

member?(name, key)

member?(atom(), any()) :: boolean()

Check if the key is present in the given table.

Link to this function

mode(name, value)

mode(atom(), :both | :read!) :: o()

Change the access mode of the given table, see mnesia:change_table_access_mode.

Modes

  • :both sets read and write mode, it's the default.
  • :read! sets read-only mode.
Link to this function

move_copy(name, from, to)

move_copy(atom(), node(), node()) :: o()

Move the copy of the given table from the given node to another given node, see mnesia:move_table_copy.

Link to this function

next(name, key)

next(atom(), any()) :: any() | nil | no_return()

Get the next key in the table starting from the given key, see mnesia:next.

Link to this function

next!(name, key)

next!(atom(), any()) :: any() | nil | no_return()

Get the next key in the table starting from the given key, see mnesia:dirty_next.

Link to this function

ordered_set?(name)

ordered_set?(atom()) :: boolean()

Check if the given table is an ordered set.

Link to this function

prev(name, key)

prev(atom(), any()) :: any() | nil | no_return()

Get the previous key in the table starting from the given key, see mnesia:prev.

Link to this function

prev!(name, key)

prev!(atom(), any()) :: any() | nil | no_return()

Get the previous key in the table starting from the given key, see mnesia:dirty_prev.

Link to this function

priority(name, value)

priority(atom(), integer()) :: o()

Change the given table loading priority.

Link to this function

properties(name)

properties(atom()) :: Keyword.t()

Return properties of the given table.

Link to this function

read(name, key, lock \\ :read)

read(atom(), any(), :read | :write | :write!) :: [tuple()] | nil | no_return()

Read records from the given table with the given key, locking in the given mode, see mnesia:read.

  • :write sets a :write lock
  • :write! sets a :sticky_write lock
  • :read sets a :read lock
Link to this function

read!(name, key)

read!(atom(), any()) :: [tuple()] | nil | no_return()

Read records from the given table with the given key, see mnesia:dirty_read.

Link to this function

read_at(name, key, position)

read_at(atom(), any(), integer() | atom()) :: [tuple()] | nil | no_return()

Read records on the given table based on a secondary index given as position, see mnesia:index_read.

Link to this function

read_at!(name, key, position)

read_at!(atom(), any(), integer() | atom()) :: [tuple()] | nil | no_return()

Read records on the given table based on a secondary index given as position, see mnesia:dirty_index_read.

Link to this function

select(name, spec)

select(atom(), any()) :: Amnesia.Selection.t() | nil | no_return()

Select records in the given table using a match_spec, see mnesia:select.

Link to this function

select(name, limit, spec)

select(atom(), integer() | :read | :write, any()) ::
  Amnesia.Selection.t() | nil | no_return()

Select records in the given table using a match_spec passing a limit or a lock kind, see mnesia:select.

Link to this function

select(name, lock, limit, spec)

select(
  atom(),
  integer() | :read | :write,
  integer() | :read | :write,
  integer()
) :: Amnesia.Selection.t() | nil | no_return()

Select records in the given table using a match_spec passing a limit and a lock kind, see mnesia:select.

Link to this function

select!(name, spec)

select!(atom(), any()) :: Amnesia.Selection.t() | nil | no_return()

Select records in the given table using a match_spec, see mnesia:dirty_select.

Link to this function

set?(name)

set?(atom()) :: boolean()

Check if the given table is a set.

Link to this function

stream(name, lock \\ :read)

Link to this function

transform(name, attributes)

transform(atom(), [atom()]) :: o()

Transform a table, useful to change tables in a running instance, see mnesia:transform_table.

Link to this function

transform(name, attributes, fun)

transform(atom(), [atom()] | atom(), (tuple() -> tuple()) | [atom()]) :: o()

Transform a table, useful to change tables in a running instance, see mnesia:transform_table.

Link to this function

transform(name, new_name, attributes, fun)

transform(atom(), atom(), [atom()], (tuple() -> tuple())) :: o()

Transform a table, renaming it, useful to change tables in a running instance, see mnesia:transform_table.

Link to this function

type(name)

type(atom()) :: :set | :ordered_set | :bag

Return the type of the given table.

Link to this function

wait(names, timeout \\ :infinity)

wait([atom()], integer() | :infinity) ::
  :ok | {:timeout, [atom()]} | {:error, atom()}

Wait for the passed tables for the given timeout, see mnesia:wait_for_tables.

Link to this function

write(name, data, lock \\ :write)

write(atom(), tuple(), :write | :write!) :: :ok | no_return()

Write the given record in the given table, using the given lock, see mnesia:write.

Locks

  • :write sets a :write lock
  • :write! sets a :sticky_write lock
Link to this function

write!(name, data)

write!(atom(), tuple()) :: :ok | no_return()

Write the given record in the given table, see mnesia:dirty_write.