How to connect to SQLite database in Web Worker?

How can I connect to SQLite database from Web Worker?

Can I use Cordova-sqlite-storage or do I have to use sql.js library?

  • In Angular initialization:
.run(function($ionicPlatform, DB) {
      if (window.cordova ) {
        DB.init();
      });
})
  • In Angular service:
.factory('DB', function($q, DB_CONFIG, $cordovaSQLite, DebugPanel) {
    var self = this;
    self.db = null;
    self.isProduction = !!window.cordova;
    self.init = function() {
        if( self.isProduction ) {
            // self.db = $cordovaSQLite.openDB({name: DB_CONFIG.name, location: 1});
            self.db = $cordovaSQLite.openDB({name: "db-1.db", location: 1});
        }
    };
    return self;
})