0.0.3 • Published 3 years ago
json-store-list v0.0.3
json-store-list
Simple JSON database to use with a Rest Api.
npm i --save json-store-listThis 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');Functions
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) {...})