Getting Started
View Source- Add
factto your list of dependencies inmix.exs:
def deps do
[{:fact, "~> 0.2.1"}]
end- If you are using Elixir
1.17.xor earlier, addjasonto support JSON serialization:
def deps do
[
{:fact, "~> 0.2.1"},
{:jason, "~> 1.4"}
]
end- Fetch the dependencies:
$ mix deps.get
- Use mix to create a new database:
$ mix fact.create -p tmp/factdb
- Test it out via
iex:
$ iex -S mix
iex> {:ok, db} = Fact.open("tmp/factdb")
iex> Fact.read(db, :all)
- Add it to your supervision tree:
# Inside your Supervisor module's init
children = [
{Fact.Supervisor, databases: ["tmp/factdb"]}
]
- Lookup the database id by name and used as the handle for operations.
# Else where in your code.
{:ok, db} = Fact.Registry.get_database_id("factdb")
You've got want you need, check the Fact module docs for details on appending, reading, and subscribing.