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.
npm install whoadb
WhoaDB = require 'whoadb'persistFile = '/tmp/whoadb.json'db = persistFile
record1 = id: 'fff'name: "food"_collection: "edibles"record2 = id: 'ggg'name: "more food"_collection: "edibles"dbsaverecord1dbsaverecord2dball'edibles'# => [ record1, record2 ]dbfind'edibles''fff'# => record1
record = name: "food"_collection: "edibles"dbsaverecord# record object is assigned an idrecord.name = "non-food"dbsaverecord# record updateddbdestroyrecord
If a record doesn't have a
_collection key, it'll be added to the
record1 = id: 'fff'name: "food"dbsaverecord1dball# => [ record1 ]dbfind'fff'# => record1