简体   繁体   中英

How to manage large java script data files?

I'm developing a Cordova project. to store my data I'm using java script files like this:

var groups = [
    {
        id: 1,
        parent_id: 0,
        name: "Group 1"
    },
    {
        id: 2,
        parent_id: 0,
        name: "Group 2"
    }
];

First problem is that I don't know if it is a good way or maybe there are better ways.
to use this data, simply I use a loop through variable, but the problem is when there are large data volumes, for example thousands of records. It's hard to handle this amount of data in a .js file. what should I do?

A possible solution is to use a database such as IndexedDB(if your app is completely offline) or FireBase (if your app uses internet), you can query and get just the data you require.

Even DOM Storage (Local-Storage) is an option but there is the problem of looping over an array and this cannot store more than 5MB of data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM