开发者

LocalStorage or SQLite Database?

开发者 https://www.devze.com 2023-03-27 09:41 出处:网络
I\'m currently developing a mobile application which uses AJAX request to get data from a server. To enable offline navigation in my application, I need to store all data collected.

I'm currently developing a mobile application which uses AJAX request to get data from a server.

To enable offline navigation in my application, I need to store all data collected.

My application is quite powerful because there's a section where the user can see charts (powered by highcharts).

I'm asking myself about the best solution to ca开发者_如何学编程che the data collected in the JSON format.

Is it light or efficient enough to JSON.stringify the data array into local storage like:

localStorage.setItem("graph_1_datas", JSON.stringify(json_data_array));

Or would it be better to create a database, and a table like that:

TABLE
-----
id
graphId
blockId
x
y

I have 3 graphIds by blockId, and about 10 blockIds...


Storing the JSON strings to local storage should be fairly fast and efficient. Just store a separate file for each request and then it will give you clear simple code for getting the data either from local storage or web service.

If you are likely to want to edit the data offline then you may wish to consider an SQLite database as it will make it easier/more efficient to add code to track changes.

You may also want to consider an SQLite database if your object graph gets more complicated and fits a relational database model.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号