CPub.DB (CPub v0.3.0) View Source

Helpers to access Database.

Also implements a Task that is used to initialize tables.

Link to this section Summary

Functions

Abort transaction with reason.

Returns a specification to start this module under a supervisor.

The nodes where data is persisted.

Reset the entire database.

Run a database transaction.

Write a record to a table.

Link to this section Functions

Specs

abort({:error, atom()} | atom()) :: no_return()

Abort transaction with reason.

Returns a specification to start this module under a supervisor.

arg is passed as the argument to Task.start_link/1 in the :start field of the spec.

For more information, see the Supervisor module, the Supervisor.child_spec/2 function and the Supervisor.child_spec/0 type.

Specs

nodes() :: [node()]

The nodes where data is persisted.

Specs

reset() :: :ok | no_return()

Reset the entire database.

WARNING: Use with extreme caution as this will drop all data!

Specs

run(any()) :: :ok | no_return()

Specs

start_link(keyword()) :: GenServer.on_start()

Specs

transaction((... -> any())) :: :ok | any() | {:ok, any()} | {:error, any()}

Run a database transaction.

If called from within transaction the transaction will be reused.

Link to this function

write(record, opts \\ [])

View Source

Specs

Write a record to a table.