fsdb v0.2.1 Fsdb

API module.

Standard API

  :ok = Fsdb.create("table1")
  {1, "row1"} = Fsdb.insert("table1", "row1")
  {1, "row1+"} = Fsdb.update("table1", 1, "row1+")
  {1, "row1+"} = Fsdb.fetch("table1", 1)
  {1, "row1+"} = Fsdb.delete("table1", 1)
  {:not_found, "table1", 1} = Fsdb.fetch("table1", 1)
  [] = Fsdb.list("table1")
  #bypass the id generator
  {2, "row2"} = Fsdb.save("table1", 2, "row2")
  {3, "row3"} = Fsdb.save("table1", 3, "row3")
  #FIXME tuples may not be ID ordered
  [{2, "row2"}, {3, "row3"}] = Fsdb.list("table1")
  :ok = Fsdb.drop("table1")

Extended API

  path = Path.expand("~/.fsdb")
  {:ok, pid} = Fsdb.Server.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")
  #bypass the id generator
  {2, "row2"} = Fsdb.save(pid, "table1", 2, "row2")
  {3, "row3"} = Fsdb.save(pid, "table1", 3, "row3")
  #FIXME tuples may not be ID ordered
  [{2, "row2"}, {3, "row3"}] = Fsdb.list(pid, "table1")
  :ok = Fsdb.drop(pid, "table1")
  :ok = Fsdb.Server.stop(pid)

Summary

Functions

Creates a table with name table

Same as above but addresses an specific Fsdb.Server

Deletes the row in table table having the id id

Same as above but addresses an specific Fsdb.Server

Drops the table named table

Same as above but addresses an specific Fsdb.Server

Fetches the row in table table having the id id

Same as above but addresses an specific Fsdb.Server

Inserts row row in table table with auto generated ID

Same as above but addresses an specific Fsdb.Server

Returns all rows in table table

Same as above but addresses an specific Fsdb.Server

Inserts or updates row row in table table with specific id id

Same as above but addresses an specific Fsdb.Server

Updates the row in table table having the id id

Same as above but addresses an specific Fsdb.Server

Functions

create(table)

Creates a table with name table.

Returns :ok.

create(pid, table)

Same as above but addresses an specific Fsdb.Server.

pid can be either a pid or a registered name.

delete(table, id)

Deletes the row in table table having the id id.

Returns {id, row} | {:not_found, table, id}.

delete(pid, table, id)

Same as above but addresses an specific Fsdb.Server.

pid can be either a pid or a registered name.

drop(table)

Drops the table named table.

Returns :ok.

drop(pid, table)

Same as above but addresses an specific Fsdb.Server.

pid can be either a pid or a registered name.

fetch(table, id)

Fetches the row in table table having the id id.

Returns {id, row} | {:not_found, table, id}.

fetch(pid, table, id)

Same as above but addresses an specific Fsdb.Server.

pid can be either a pid or a registered name.

insert(table, row)

Inserts row row in table table with auto generated ID.

Returns {id, row}.

insert(pid, table, row)

Same as above but addresses an specific Fsdb.Server.

pid can be either a pid or a registered name.

list(table)

Returns all rows in table table.

Returns [{id, row}, ...].

list(pid, table)

Same as above but addresses an specific Fsdb.Server.

pid can be either a pid or a registered name.

save(table, id, row)

Inserts or updates row row in table table with specific id id.

Returns {id, row}.

save(pid, table, id, row)

Same as above but addresses an specific Fsdb.Server.

pid can be either a pid or a registered name.

update(table, id, row)

Updates the row in table table having the id id.

Returns {id, row} | {:not_found, table, id}.

update(pid, table, id, row)

Same as above but addresses an specific Fsdb.Server.

pid can be either a pid or a registered name.