WhoaDB(!)
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.
Starting
npm install whoadb
WhoaDB = require 'whoadb' persistFile = '/tmp/whoadb.json' db = persistFile
Finding
record1 = id: 'fff'name: "food"_collection: "edibles" record2 = id: 'ggg'name: "more food"_collection: "edibles" dbsaverecord1dbsaverecord2 dball'edibles' # => [ record1, record2 ] dbfind'edibles''fff' # => record1
Create & Update & Destroy
record = name: "food"_collection: "edibles" dbsaverecord # record object is assigned an id record.name = "non-food" dbsaverecord # record updated dbdestroyrecord
_collection
key
Records without the If a record doesn't have a _collection
key, it'll be added to the
undefined
collection.
record1 = id: 'fff'name: "food" dbsaverecord1 dballundefined # => [ record1 ] dbfindundefined'fff' # => record1