CubDB - A pure-Elixir embedded database

Completely reasonable question! If you aren’t used to this pattern, it can be hard to know what to do here.

  1. Pass a :name argument to start_link — this will be forwarded to the underlying GenServer and accessible throughout your application.

  2. You probably don’t want to be calling start_link directly, but letting your application supervisor do so. So here’s the pattern you’re probably going to want to use:

children = [
  {CubDB, data_dir: “some/dir”, name: :my_db}
]

Supervisor.start_link(children, strategy: :one_for_one)

You’d then use :my_db wherever you need to pass the db into the CubDB API.

5 Likes