0.3.0 • Published 7 years ago

proud-db v0.3.0

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

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

Kind: global function Returns: Promise - resolves to true

ParamTypeDescription
parentstring
childKeystring
childValueanycan 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

ParamTypeDescription
parentstring
childKeystringdescription

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

ParamType
parentstring
childKeystring

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

ParamType
parentstring

saveParent(parent, data) ⇒ Promise

saveParent - save a parent record

Kind: global function Returns: Promise - resolves to true

ParamTypeDescription
parentstring
dataanydata 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

ParamType
parentstring
childKeystring

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

0.3.0

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago