Loading JSON file into forrunner db file and vice versa ?
I need to convert my JSON files into forrunner db files and after doing frontend changes then convert into back in JSON file and pass it to the server , because my JSON is in native so it only understand JSON file not db file . does any one have idea how to do this ?
Hi ya,
Bit confused here... why don't you just send and receive JSON? Is there a specific case where you need to manipulate the .db files directly?
yes because i have a large data set in jSON format so for searching purpose and for loading performance i need data instant that can be possible via Database because if i do manipulation in JSON boject for searching , i did using recursion and check whether its have or not , if it have that store in array and not then move further check its children . this is for each entry in JSON this is time consuming and consuming so much memory so to avoid this i want to search in database .
Hey,
So my understanding from your message:
- You have a large data set
- You want to use ForerunnerDB because it makes it really easy to query that data set
I'm still a bit confused why you need to create / manipulate db files directly.
Surely you can do:
On the server: Get your data set and send it to the client in JSON format On the client: Receive your data set in JSON and insert into ForerunnerDB and then query it
Can you explain a bit more what the issue you are trying to solve is? Thanks!
yes i have a large data set .
i am using Angular 4 primeNG treetable view in which i am sending JSON data object as a argument and it display to me ,
for small dataset its loading and searching is good but for large it fails so for that i am trying to send some data i.e on Demand from database .
but in my secenerio i have server which is native so it only create data in JSON file .json extension not in forerunner DB file standard .
so that JSON file i want to give to the database when client send me request for the data and manipulate according to his/her need .
after manipulation i want export that data to JSON file and pass to the server component.
so can i do import and export of JSON file in this data or not .
Yes you can import and export from ForerunnerDB in JSON format easily.
To import just create a collection and use insert() or setData().
To export, simply run a find query without any query object fields:
var myJson = collection.find({});
// Now send the myJson to the server or wherever.
or you can suggest me something for searching something in large nested JSON data set quickly . i am using the following given approach , so you have any please suggest
filterFields(object) {
let res = false;
if (object.name) {
let name = object.name;
res = name.toLowerCase().includes(this.globalFilter.value.toString().toLowerCase())
}
return res;
}
filterChildren(children, parent) {
let res = false;
if (children) {
children.map(child => {
let _fields = this.filterFields(child.data);
let _children = this.filterChildren(child.children, child);
res = _fields || _children || res;
});
parent.expanded = res;
}
return res;
}
filter(node) {
let res = false ;
res= this.filterFields(node.data) || this.filterChildren(node.children,node);
return res;
}
among searching via above solution or via forrunnerDB , which one is good option ?
I am using the below code for printing the JSON data on the console but nothing is happen , no error nothing.
just running the following code using node connection.js command
Connection.js file
I am doing so `var ForerunnerDB = require("forerunnerdb"); var fdb = new ForerunnerDB(); var db = fdb.db("jardatabase"); var collection = db.collection("first"); collection.insert("./data.json"); // try with as well //collection.insert("data.json"); console.log(" lets see any possiblites"+collection.find({}));
`