javascript - Client Side Storage with Web SQL Database - Stack Overflow

My application uses client side database storage using webSQL to store information for the user. I have

My application uses client side database storage using webSQL to store information for the user. I have heard that browsers are starting to turn away from webSQL. Currently only chrome, safari and Opera support it. Because IE and Firefox don't support webSQL I am using cookies to store information if the user is using those browsers. However cookies are not very secure and it is difficult to store large amounts of data. My question is then, is there any better option right now similar to the javascript API that all browsers support? Thanks.

My application uses client side database storage using webSQL to store information for the user. I have heard that browsers are starting to turn away from webSQL. Currently only chrome, safari and Opera support it. Because IE and Firefox don't support webSQL I am using cookies to store information if the user is using those browsers. However cookies are not very secure and it is difficult to store large amounts of data. My question is then, is there any better option right now similar to the javascript API that all browsers support? Thanks.

Share Improve this question asked Jul 24, 2012 at 15:59 eweinewein 2,7356 gold badges40 silver badges57 bronze badges 1
  • 1 If you're looking for something truly cross-browser, you're out of luck for the time being (until HTML5 is official anyway). LocalStorage should eventually do the job, but simulating an RDBMS in the browser might be a little overkill. Storing anything client-side is inherently insecure, as it's in the control of the client. – Widor Commented Jul 24, 2012 at 16:22
Add a ment  | 

2 Answers 2

Reset to default 4

I think IndexedDB would be an option for you which is an Object based data store. It is currently supported by Chrome, Firefox and IE 10 will also support it in future.

Have a look at the following presentation to get a better understanding http://html5-demos.appspot./static/html5storage/index.html#slide1

From my experience I would suggest to use a wrapper library just to reduce the risk in future changes in browsers. Few popular libraries are given below

  1. Storage polyfill By Remy Sharp
  2. Amplify.js By appendTo HTML5 API with fallbacks for HTML4 browsers (including IE6)
  3. RealStorage HTML5 API is a subset of overall API
  4. YUI3 CacheOffline by YUI team
  5. Persistence.js Asynchronous Javascript object-database mapper
  6. YDN-DB Easy to use database wrapper for IndexedDB, WebSql and localStorage build on top of closure library.

I'm a couple of years late, but given the developments in the client-side browser space since this question was asked, I thought I'd add in my two cents.

At the time this question was asked, IndexedDB was the only alternative WebSQL, though support for it was spotty at the time. Though today the former still holds true, the latter does not: now, all of the major browser vendors have an implementation of IndexedDB.

Considering IndexedDB is the only database that remains on the W3C standards track at this point, it is pretty much the only option as far as native client-side databases go.

But before you dive in to IndexedDB, there are a couple of things you should know about it. The first is that it is a non-relational document store, and as such does not natively support SQL. The second is that its API is... unwieldy to say the least.

Given these things, I suggest you check out BakedGoods. With it, placing one or more data items in an IndexedDB database, for example, is as simple as:

bakedGoods.set({
    data: [{key: "key1", value: "value1"}, {key: "key2", value: "value2"}],
    storageTypes: ["indexedDB"],
    function(byStorageTypeStoredItemRangeDataObj, byStorageTypeErrorObj){}
});

Of course, if you're some sort of masochist, you could ignore my suggestion and deal with the raw API. But don't say I didn't warn you !

For the sake of plete transparency, BakedGoods is maintained by yours truly :) .

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745316366a4622236.html

相关推荐

  • javascript - Client Side Storage with Web SQL Database - Stack Overflow

    My application uses client side database storage using webSQL to store information for the user. I have

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信