Getting Started

View Source
  1. Add fact to your list of dependencies in mix.exs:
def deps do
  [{:fact, "~> 0.2.1"}]
end
  1. If you are using Elixir 1.17.x or earlier, add jason to support JSON serialization:
def deps do
  [
     {:fact, "~> 0.2.1"},
     {:jason, "~> 1.4"}
  ]
end
  1. Fetch the dependencies:
$ mix deps.get
  1. Use mix to create a new database:
$ mix fact.create -p tmp/factdb
  1. Test it out via iex:
$ iex -S mix

iex> {:ok, db} = Fact.open("tmp/factdb")

iex> Fact.read(db, :all)
  1. Add it to your supervision tree:
# Inside your Supervisor module's init

children = [
  {Fact.Supervisor, databases: ["tmp/factdb"]}
]
  1. 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.