ecto_mnesia v0.6.1 Ecto.Mnesia.Table

This module provides interface to perform CRUD and select operations on a Mnesia table.

Summary

Functions

Get list of attributes that defined in Mnesia schema

Get count of records in a Mnesia table

Delete record from Mnesia table by key

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

Read record from Mnesia table

Get Mnesia table name by binary or atom representation

Insert a record into Mnesia table

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

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

Returns auto-incremented integer ID for table in Mnesia

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

Select all records that match MatchSpec. You can limit result by passing third optional argument

Run function fun inside a Mnesia transaction with specific context

Read record in Mnesia table by key

Functions

attributes(table)

Get list of attributes that defined in Mnesia schema.

count(table)

Get count of records in a Mnesia table.

delete(table, key, opts \\ [])

Delete record from Mnesia table by key.

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

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

get(table, key, opts \\ [])

Read record from Mnesia table.

get_name(table)

Get Mnesia table name by binary or atom representation.

insert(table, record, opts \\ [])

Insert a record into Mnesia table.

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

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

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

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

next_id(table, inc \\ 1)

Returns auto-incremented integer ID for table in Mnesia.

Sequence auto-generation is implemented as mnesia:dirty_update_counter.

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

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

select(table, match_spec, limit \\ nil)

Select all records that match MatchSpec. You can limit result by passing third optional argument.

transaction(fun, context \\ :transaction)

Run function fun inside a Mnesia transaction with specific context.

Make sure that you don’t run any code that can have side-effects inside a transactions, because it may be run dozens of times.

By default, context is :transaction.

update(table, key, record, opts \\ [])

Read record in Mnesia table by key.

You can partially update records by replacing values that you don’t want to touch with nil values. This function will automatically merge changes stored in Mnesia and update.