README.md

# fsdb

Very simple filesystem database with Erlang term text serialization (Erlang's JSON).
Each table is a folder and each row is a file.
Any Erlang term can be persisted as a row.
Rows have auto generated ids.
Row files are human readable.

Wrote this out of frustration that current versions of sqlite_ecto (1.1.0) and Phoenix (1.2.0) are incompatible. Postgres is overkill for small projects or standalone applications that need to keep track of small persistent chunks of data.

## Installation

  1. Add `fsdb` to your list of dependencies in `mix.exs`:

    ```elixir
    def deps do
      [{:fsdb, "~> 0.1.0"}]
    end
    ```

  2. Use it

    ```elixir
    path = Path.expand("~/.db")
    {:ok, pid} = Fsdb.start_link([path: path])
    :ok = Fsdb.create(pid, "table1")
    {1, "row1"} = Fsdb.insert(pid, "table1", "row1")
    {1, "row1+"} = Fsdb.update(pid, "table1", 1, "row1+")
    {1, "row1+"} = Fsdb.fetch(pid, "table1", 1)
    {1, "row1+"} = Fsdb.delete(pid, "table1", 1)
    {:not_found, "table1", 1} = Fsdb.fetch(pid, "table1", 1)
    [] = Fsdb.list(pid, "table1")
    {2, "row2"} = Fsdb.insert(pid, "table1", "row2")
    {3, "row3"} = Fsdb.insert(pid, "table1", "row3")
    #FIXME how to ensure order?
    [{2, "row2"}, {3, "row3"}] = Fsdb.list(pid, "table1")
    :ok = Fsdb.drop(pid, "table1")
    Fsdb.stop(pid)
    ```

## Roadmap

Version 0.1.0
- [x] create, drop support
- [x] insert, fetch, update, delete, list support
- [x] Erlang text term serialization support