Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading JSON file into forrunner db file and vice versa ? #241

Open
goel-sunny opened this issue Apr 2, 2018 · 8 comments
Open

Loading JSON file into forrunner db file and vice versa ? #241

goel-sunny opened this issue Apr 2, 2018 · 8 comments
Labels

Comments

@goel-sunny
Copy link

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 ?

@Irrelon
Copy link
Owner

Irrelon commented Apr 3, 2018

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?

@goel-sunny
Copy link
Author

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 .

@Irrelon
Copy link
Owner

Irrelon commented Apr 3, 2018

Hey,

So my understanding from your message:

  1. You have a large data set
  2. 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!

@goel-sunny
Copy link
Author

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 .

@Irrelon
Copy link
Owner

Irrelon commented Apr 3, 2018

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.

@goel-sunny
Copy link
Author

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;
    }

@goel-sunny
Copy link
Author

among searching via above solution or via forrunnerDB , which one is good option ?

@goel-sunny
Copy link
Author

goel-sunny commented Apr 5, 2018

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({}));

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants