Proud-db
Proud with simplicity JSON database on top of fs-extra"
Argumentation
Born from a frustration of Firebase change of direction, which left me in no man's land. I figure out that change to MongoDB seems most appropriate, but I wanted to postpone the migration. So I wrote proud-db, as I didn't found simple enough JSON database to allow me to do that.
The name
Dedication to James Brown and his song "Say It Loud – I'm Black and I'm Proud"
Example usage
// npm i -S proud-dbconst db = db//=> DB state - {parent:{key:"value"}}db//=> DB state - {parent:{key:"big payback"}}db //=> return "big payback"
More examples you can find in the test file "testPre.js"
Location of the JSON file
It is located in the root directory of the library, so you should see at "./node_modules/proud-db/_db.json"
Functions
- save(parent, childKey, childValue) ⇒
Promise
save - store a record to the json file
- load(parent, childKey) ⇒
Promise
load - fetch a record from the database
- remove(parent, childKey) ⇒
Promise
remove - remove a record
- loadParent(parent) ⇒
type
loadParent - fetch a parent record
- saveParent(parent, data) ⇒
Promise
saveParent - save a parent record
- removeParent(parent, childKey) ⇒
Promise
removeParent - remove a parent record
- loadAll() ⇒
Promise
loadAll - load the whole database
Promise
save(parent, childKey, childValue) ⇒ save - store a record to the json file
Kind: global function
Returns: Promise
- resolves to true
Param | Type | Description |
---|---|---|
parent | string |
|
childKey | string |
|
childValue | any |
can be any Javascript type |
Promise
load(parent, childKey) ⇒ load - fetch a record from the database
Kind: global function
Returns: Promise
- resolves to the record if loading is successfull or to null on missing record
Param | Type | Description |
---|---|---|
parent | string |
|
childKey | string |
description |
Promise
remove(parent, childKey) ⇒ remove - remove a record
Kind: global function
Returns: Promise
- resolves to true on successfull removal or to null on an already missing record
Param | Type |
---|---|
parent | string |
childKey | string |
type
loadParent(parent) ⇒ loadParent - fetch a parent record
Kind: global function
Returns: type
- resolves to the record if loading is successfull or to null on a missing record
Param | Type |
---|---|
parent | string |
Promise
saveParent(parent, data) ⇒ saveParent - save a parent record
Kind: global function
Returns: Promise
- resolves to true
Param | Type | Description |
---|---|---|
parent | string |
|
data | any |
data to be saved |
Promise
removeParent(parent, childKey) ⇒ removeParent - remove a parent record
Kind: global function
Returns: Promise
- resolves to true on successfull removal or to null on an already missing record
Param | Type |
---|---|
parent | string |
childKey | string |
Promise
loadAll() ⇒ loadAll - load the whole database
Kind: global function
Returns: Promise
- resolves to true on successfull removal or to null on an already missing record