fsdb v0.3.0 Fsdb

Fsdb module.

  #run with: mix sample_direct

  db = Path.expand("_build/dev/.fsdb")

  :ok = Fsdb.init(db)

  #drop to start over
  :ok = Fsdb.drop(db, "table1")

  :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 nonexisting 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")

Link to this section Summary

Link to this section Functions

Link to this function create(path, table)
Link to this function delete(path, table, id)
Link to this function drop(path, table)
Link to this function fetch(path, table, id)
Link to this function insert(path, table, row)
Link to this function list(path, table)
Link to this function save(path, table, id, row)
Link to this function update(path, table, id, row)