Simple JSON database to use with a Rest Api.
npm i --save json-store-list
This module is inspired from juliangruber/json-store. The main difference is that json-store-list
store data as an array and asynchronously.
First init the store (make sure that the path is correctly defined):
var JSONStore = require('json-store-list');
var db = JSONStore('./index.json');
db.getAll()
: get the whole filedb.get(label, key, cb)
: search an object, example:db.get('id', 1, function (err, obj) {...})
db.post(obj, cb)
: add a new object in the storedb.delete(label, key, cb)
: delete an object, example:db.delete('id', 1, function (err) {...})
db.put(label, key, newValue, cb)
: replace an object by a new one, example:db.put('id', 1, {id: 3, name:'new'}, function (err) {...})