0.0.0 • Published 5 years ago

json-store-object v0.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

json-store-obhect

Build Status

Simple JSON database to store properties.

npm i --save json-store-object

First init the store (make sure that the path is correctly defined):

var JSONStore = require('json-store-object');

var defaultObject = { // Object to consider if the file do not exists
    up: false
}

var defaultReturn = null; // Value to return if the key do not exist do not exists

var db = JSONStore(defaultObject, defaultReturn,'./index.json');

Functions

  • db.getAll(): get the whole file
  • db.get(key, cb): get a property, example: db.get('up' function (err, obj) {...})
  • db.put(key, value, cb): edit a property in the store or create it, example: db.put('up', true, function (err) {...})
  • db.delete(key, cb): delete a property, example: db.delete('up', function (err) {...})