Store and read JSON objects in a flat file if you want!
Not actually a DB: But read/write JSON objects to/from a flat file using this if you want.
This is a component I extracted from a test REST server used if you're working on a front end app that RESTfully stores data and you want to click around for a little bit without firing up an actual backend.
WhoaDB = require 'whoadb'persistFile = '/tmp/whoadb.json'db = persistFile
record1 = id: 'fff'name: "food"_collection: "edibles"record2 = id: 'ggg'name: "more food"_collection: "edibles"dbinsertrecord1dbinsertrecord2dball'edibles'# => [ record1, record2 ]dbfind'edibles''fff'# => record1
record = name: "food"_collection: "edibles"dbinsertrecord# record object is assigned an idrecord.name = "non-food"dbinsertrecord# record updateddbdestroyrecord
If a record doesn't have a
_collection key, it'll be added to the
record1 = id: 'fff'name: "food"dbinsertrecord1dballundefined# => [ record1 ]dbfindundefined'fff'# => record1
I'll be throwing the aforementioned test REST server up here as well so the existence of this in isolation doesn't seem quite so damned weird.