The most recent project used the front-end storage, originally selected Localstorage, this is the HTML5 inside the new API, the usage is very simple. SetItem GetItem Clear. It is important to note that the data stored in the Localstorage in the form of a string, the time taken out is also in the form of a string to get. because the general data in the project is stored in JSON or array mode. Json.parse and json.stringify are therefore required prior to access.
Another inconvenience in localstroage is that it is simply a data store with no self-increment ID. This does not say, when fetching data, can only traverse the search, for example, you want to find a time period of data, here is only a traversal query. The amount of data is not what, the amount of data is really troublesome, after all, it is easy to traverse, who can bear.
There are similarities between Web SQL and common MySQL. The language of the operation is also an SQL statement. Support Some SQL common find Ah, add AH update what. I think it's still better, and the mobile side should have no problem. But there seems to be some problems with browser compatibility on the PC. Because our project soon found an alternative to the Localforage Web SQL has not yet been thoroughly researched.
Localforage is developed by Mozilla, the advantages: 1. Same as Localstorage but when you access data, you can save data in arrays, JSON, and other formats, without having to change the data format any further. In addition, the Localstroage access data is synchronous, while the localforage is asynchronous and supports promise mode. This cannot be said to be superior or inferior, and synchronization has the advantage of synchronization.
Localforage also does not support SQL queries, like Localstorage, can only do simple data access, so to see, the larger front-end data storage, or Web SQL will be more useful. It's a little confusing to write that Localforage is based on localstroage Web SQL and how does IT support SQL queries?
Localstorage, Localforage, the comparison of web SQL three