JavaScript Library to Bridge IndexedDB and WebSQL

后端 未结 6 1303
野的像风
野的像风 2020-12-23 02:50

I\'m curious if there is a library or a project out there to provide a generic interface to IndexedDB or to WebSQL, depending on user\'s browser\'s support. If they\'re usin

6条回答
  •  盖世英雄少女心
    2020-12-23 03:08

    The question is answered, I just want to share the updates.

    In May 2012 JayData has been released, which is the unified data access library for JavaScript and helps to manage data in IndexedDB, WebSQL, SQLite, MongoDB, HTML5 localStorage databases and Facebook, OData, WebAPI, YQL data services with the same JavaScript Language Query syntax.

    Changing to IndexedDB from WebSQL means only changing type of the storage provider:

    var todoDB = new TodoDatabase({ 
        provider: 'webSql', databaseName: 'MyTodoDatabase' });
    
    var todoDB = new TodoDatabase({ 
        provider: 'indexedDB', databaseName: 'MyTodoDatabase' });
    

    If you don't specify the provider, the library detects the available storage of the browser/device in the following priority order (WebSQL, IndexedDB, HTML5 localStorage).

    Disclaimer: I'm member of the developer team of the open-source JayData project

提交回复
热议问题