fsdb

Minimal 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 keeping track of small persistent chunks of data.

Installation and Usage

  1. Add fsdb to your list of dependencies in mix.exs:
```elixir
def deps do
[{:fsdb, "~> 0.2.4"}]
end
```
  1. Run the sample:
```elixir
#run with: mix sample
{:ok, db} = Fsdb.start_link(Path.expand("_build/dev/.fsdb"))
#drop to start over
:ok = Fsdb.drop(db, "table1")
#creates table at dev default _build/dev/.fsdb
#configure path with: config :fsdb, path: <NEW_PATH>
:ok = Fsdb.create(db, "table1")
#insert generates and returns an autoincrementing id
{:ok, 1} = Fsdb.insert(db, "table1", "row1")
{:ok, "row1"} = Fsdb.fetch(db, "table1", 1)
#operation on unexisting ids return not found
:nf = Fsdb.delete(db, "table1", 5)
:nf = Fsdb.update(db, "table1", 5, "row5+")
#save overrides and updates id generator
:ok = Fsdb.save(db, "table1", 5, "row5")
:ok = Fsdb.save(db, "table1", 3, "row3")
#continue +1 of largest id used/generated before
{:ok, 6} = Fsdb.insert(db, "table1", "row6")
#operations that get back previous value
{:ok, "row5"} = Fsdb.update(db, "table1", 5, "row5+")
{:ok, "row5+"} = Fsdb.save(db, "table1", 5, "row5++")
{:ok, "row5++"} = Fsdb.delete(db, "table1", 5)
#tuples may not be id ordered
[{1, "row1"}, {3, "row3"}, {6, "row6"}] = Fsdb.list(db, "table1")
```
  1. Run the tests
```shell
mix test
```

Releases

Version 0.2.5

Version 0.2.4

Version 0.2.3

Version 0.2.2

Version 0.2.1

Version 0.2.0

Version 0.1.0