Featherweight writing and reading object to/from json files.
npm i object-to-file --save
https://npm.runkit.com/object-to-file
var objectToFile = require("object-to-file")
var db = new objectToFile.default("testing-runkit");
db.push("Greeting", { Hello: "World"});
db.read("Greeting");
Create a database named "database-name":
import Database from 'object-to-file';
var db = new Database("database-name");
// or...
var objectToFile = require("object-to-file");
var db = new objectToFile.default("database-name");
An empty database-name.json will be created.
Create "MyTesting" key and push an object to it:
db.push("MyTesting", { hello: "world" });
Get the object(s) of MyTesting key:
db.read("MyTesting");
object returned:
{ "hello": "world" }
Read entire file:
db.read();
object returned:
"MyTesting": {
"hello": "world"
}
Remove everything under "MyTesting" and the key:
db.delete("MyTesting");
Remove all data:
db.truncate();
Permanently remove the database (file):
db.unlink();
ts-jest to run tests (not included in )
npm run test