proud-db

0.3.0 • Public • Published

Build Status Code Climate Dependency Status Downloads npm Twitter Follow

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-db
const db = require("proud-db")
 
db.save("parent","key","value")
//=> DB state - {parent:{key:"value"}}
db.save("parent","key","big payback")
//=> DB state - {parent:{key:"big payback"}}
db.load("parent","key") //=> 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

save(parent, childKey, childValue) ⇒ Promise

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

load(parent, childKey) ⇒ Promise

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

remove(parent, childKey) ⇒ Promise

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

loadParent(parent) ⇒ type

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

saveParent(parent, data) ⇒ Promise

saveParent - save a parent record

Kind: global function Returns: Promise - resolves to true

Param Type Description
parent string
data any data to be saved

removeParent(parent, childKey) ⇒ Promise

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

loadAll() ⇒ Promise

loadAll - load the whole database

Kind: global function Returns: Promise - resolves to true on successfull removal or to null on an already missing record

Package Sidebar

Install

npm i proud-db

Weekly Downloads

2

Version

0.3.0

License

ISC

Last publish

Collaborators

  • self_refactor