开发者

Web SQL Database or Indexed Database API ... or both?

开发者 https://www.devze.com 2023-02-15 03:18 出处:网络
HTML5\'s localStorage, while a great step in the right direction, is quite incomplete for my needs; its a glorified 1-dimensional array.

HTML5's localStorage, while a great step in the right direction, is quite incomplete for my needs; its a glorified 1-dimensional array.

There are two competing client-side databases being built into modern browsers.

  • Web SQL Database (http://www.w3.org/TR/w开发者_高级运维ebdatabase/)
  • Indexed Database API (http://www.w3.org/TR/IndexedDB/)

Has anybody written and published a meta-library to both of these services? Akin to to how dojox.storage used to proxy the various plugins (http://dojotoolkit.org/api/1.3/dojox/storage/manager) would be great.

Futhermore, what has been your experience using either of these two 'standards'?


Actually there isn't two competing client-side databases being built into modern browsers, the Web SQL standard has been discontinued, in future versions of browsers there will only(*) be IndexedDB. Firefox will have it in 4.0, Chrome will have it sometime, IE will have it some time later and Opera will (so I've heard) have it in 11.50

(*)I say only, but I'm willing to bet WebKit will continue to support Web SQL for some time to come given that there's significant existing use out there, especially on iOS targeted stuff.

My personal opinion is that not blessing SQLite as a web standard is a good thing, but IndexedDB is not the thing to directly replace it. It's too low level to be really comfortable for front end developers to think about in the same way as SQL (if you've ever done that 'show execution plan' thing in SQL Server Studio, IndexedDB is basically the sort of thing you see there except without the handy diagrammatic comprehension aid). Having not yet devoted a serious chunk of time to understanding it, I haven't yet been able to figure out how to write a useful application with IndexedDB. My feeling is that it won't really take off until we see something like jQueryDB or possibly jsHibernate.

In the meantime, if a significant chunk of your users will be WebKit based, stick with Web SQL.


I was just asking myself the same question.

It happens that a pollyfill is available here (transactions are not perfectly implemented yet but if you do not need it, it might be a great choice!):

http://blog.nparashuram.com/2012/06/indexeddb-polyfill.html

Github direct link: https://github.com/axemclion

0

精彩评论

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

关注公众号