Local DB API - deprecated what is the alternative? [closed]

一世执手 提交于 2019-12-10 11:24:33

问题


The local DB api based on SQLite is going down. According to w3c it has to be replaced indexedDB. But IndexedDB API is still work in progress so no implementation yet. For an app that needs massive db storage... and for the time being; what is the alternative? What would be the most future proof?

Local storage is no option as I need to store data structured (relational), and a lot of it. Cloud based alternatives are also out of scope. I need something local.


回答1:


I would say indexeddb is the way to go. IE, FF and chrome allready support it, but for mobile devices it's still a hell. I would advice you to stay with websql for now, I think phonegap will keep supporting it for a while.

The problem with the spec was, that there isn't a standerd way to query. Every vendor used SQLite, but a spec can't be build on one product, that would be very dangerous. Also in most cases different db vendors mean different SQL dialects. This is also in contradiction with a standard way of working. This would mean you would have to check which db you are working and then use a different dialect. That is why they decided to use a uniform API called indexeddb.

All browsers that use an database like SQL lite to store the data in only the interface to query is the indexeddb API, so in that way indexeddb is something like an odbc. Only it's very simple and slim. If you want to learn more about indexeddb take a look at my blog I have several blogposts about it. This one is a good one to start with. It explains the basics of indexeddb.




回答2:


Local storage is no option as I need to store data structured (relational), and a lot of it

I asked similar questions in past, at some point I gave up trying to find a native solution. I end up with using this plugin.

The advantages are:

  1. You will not be bounded by quota limit on iOS platform (~5Mb) when using WebSQL.
  2. You are able distribute pre-populated databases. (I know there is a workaround for WebSQL as well, but it doesn't always work.)
  3. You can encrypt your database. (I don't know if you ever need this)
  4. There is no persistence problem as mentioned here.

The disadvantages are:

  1. There is no implementation for Windows yet. You might think of writing your own plugin for Windows.
  2. With Phonegap 2.1, they started to support ARC on iOS platform. As far as I tested, the plugin does not support ARC at the moment. You will need to tweak it.



回答3:


Why not try of IndexedDB wrapper of my own open source library? It works both old and new standard of IndexedDB API as well as great fail back to WebSQL. The wrapper API is very IndexedDB API centric and plan to support every single feature.



来源:https://stackoverflow.com/questions/12596579/local-db-api-deprecated-what-is-the-alternative

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!