简体   繁体   English

如何管理大型Java脚本数据文件?

[英]How to manage large java script data files?

I'm developing a Cordova project. 我正在开发一个Cordova项目。 to store my data I'm using java script files like this: 存储我的数据,我正在使用如下的Java脚本文件:

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. .js文件中很难处理这么多数据。 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. 一种可能的解决方案是使用IndexedDB(如果您的应用程序完全脱机)或FireBase(如果您的应用程序使用Internet)之类的数据库,则可以查询并仅获取所需的数据。

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. 甚至可以选择DOM Storage(本地存储),但是存在循环遍历阵列的问题,并且该数组不能存储超过5MB的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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