I have a JSON module which contains empty containers like this:
{
"files": {
"rootNeeded":[],
"folders":[],
"files":[],
"images":[],
"text":[],
"unknown":[]
},
}
and I wonder if I can push data into this from another module simply by using array.push
method. Something like ...
var myModule=require("./myJsonFile");
function(){
some magic here...
myModule.files.files.push(files);
}
and after this can I use this in a third node module like this...
//my third module
console.log(files.files)
in the end it will be like dynamic database each time when program called will be refreshed.
You can, however the changes you make will NOT be persisted. Also, if you use cluster, every process will have a different version of your object.
myJsonFile.json
mod1.js
mod2.js