Question

I'm developing an app that need to use indexedDB to store some information offline, but in the case of Safari, its not available (yet), so I need to use webSQL.

I already use this adapter for indexedDB, with enter link description here polyfill for the case of browser that doesn't support indexedDB.

Unfortunatelly, I have some major issue with the Shim, for example, on iOS Safari and Safari, when, in my app, I need to fetch some data inside the database to see if it exist it return me errors.

Like this and that :

throwDOMException@http://localhost/Dev/Websites/myWebsite/js/libs/IndexedDBShim.js:40:16

Error: Assertion Failed: 0: The operation failed because the requested database object could not be found. For example, an object store did not exist but was being opened

And this is caused by the fact that they are using kind of a hack to return some value, and even in the polyfill they say this :

// The IndexedDB Specification needs us to return an Object Store immediatly, but WebSQL does not create and return the store immediatly // Hence, this can technically be unusable, and we hack around it, by setting the ready value to false

So my question is, with the indexedDB adapter, can I add an other adapter for webSQL in parallel ?

Was it helpful?

Solution

I think your best option would be to chose the correct adapter at runtime (is that what you mean by parallel?). It should be as simple as this:

var App = Ember.Application.create();
App.deferReadiness();

if (window.indexedDB) {
    App.ApplicationAdapter = IndexedDBAdapter;
} else {
    App.ApplicationAdapter = WebSQLAdapter;
}

App.advanceReadiness();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top