Flux Database v0.0.1 FluxDatabase behaviour View Source
Integrate databases to Elixir projects.
The main approach to integrate a database is done by defining a module which
extends FluxDatabase
and implements config/0
function:
defmodule MyApp.Database do
use FluxDatabase
@impl FluxDatabase
def config do
[
database: :mnesia,
nodes: [node()],
tables: %{
user: {
:user,
attributes: [:id, :name, :email]
}
}
]
end
end
Then, call MyApp.Database.start/0
somewhere which can start the database.
It can be, for example, on your Application
module:
defmodule MyApp.Application do
use Application
@impl Application
def start(_type, _args) do
MyApp.Database.start()
children = [
]
opts = [strategy: :one_for_one]
Supervisor.start_link(children, opts)
end
end
For more information about how to integrate and use
DETS with FluxDatabase
, check
FluxDatabase.DETS
.
For more information about how to integrate and use
Mnesia with FluxDatabase
, check
FluxDatabase.Mnesia
.