Hi Node-RED,
I created a database that use JSON file to store the data.
The major advantage of my node compared to other real database is its weight. If you don't need to work with simultaneous access and you are already using the JSON node and file node to store data, this Database Node is for you.
The database load the JSON file into the memory, when needed, and at every change save the data into the file. (This behaviour can be configured to only save when the node is stopped). In other word, it's a light-weight memory database using JavaScript object with persistence.
to Install the node :
npm install json-db-node-red
It contains 2 Nodes that are put into Storage. One to store the Data and the other to retrieve it.
The major concept I implemented is DataPath. It share it's idea from XMLPath that you use to browse an XML file.
Example:
This is the data stored at the root of the database.
{
"test":"test",
"json":{
"test":[
"test"
],
"important":5
},
"new":"cool"
}
To access the array ['test'] the DataPath is : /test/json/test
This path can be used to retrieve or to change the data. And by changing I mean either overriding it or merging with new data.
Hoping it will be useful to anybody else than me. Btw, the library is highly tested with a coverage of 94% and completely synchronized.
--
Antoine Aflalo