function connect() {
        var deferred = $q.defer();  
        // console.info('connect() isConnecting_', isConnecting_);
        if (isConnecting_ === false) {
          var connectionOptions = { storeType: lf.schema.DataStoreType.INDEXED_DB };
          // if (ionic.Platform.isIOS() || ionic.Platform.isAndroid()) {
          //   connectionOptions = { storeType: lf.schema.DataStoreType.WEB_SQL };
          // }
          
          if (service.db_ === null) {
            isConnecting_ = true;
            buildSchema()
              .connect(connectionOptions)
              .then((
                function(database) {
                  isConnecting_ = false;
                  service.db_ = database;
                  service.productTable = database.getSchema().table('products');
                  service.productVariantTable = database.getSchema().table('product_variants');
                  service.orderTable = database.getSchema().table('orders');
                  service.orderItemsTable = database.getSchema().table('order_items');
                  service.customerTable = database.getSchema().table('customers');
                  service.customerGroupTable = database.getSchema().table('customer_groups');

                  deferred.resolve();
                }));
          } else {
            deferred.resolve();
          }
        } else {
          deferred.reject('Still connecting to the database');
        }
        
        return deferred.promise; 
      }
/**
      * Initializes a database connection.
      * @return {!angular.$q.Promise} - promise is resolved when the db_ and noteTable_ properties have had values assigned to them 
      * 
      * NOTE: 2015/10/10
      *       When no connection options are set LoveField does some feature detection to determine which backing store to use.
      *       If the browser supports IndexedDb it uses that, then falls back to WebSql and finally to an "in memory" data store.
      *       I found when debugging on actual devices that LoveField chose the in memory (lf.schema.DataStoreType.MEMORY) store 
      *       on iOS which didn't work so well so here we ensure WebSql is used for iOS and Android devices. 
      *       IndexedDb seemed to work well on desktop browsers. 
      *       https://github.com/google/lovefield/blob/master/docs/spec/03_life_of_db.md#311-connect-options
      *       https://cordova.apache.org/docs/en/5.1.1/cordova/storage/storage.html 
      *       http://caniuse.com/#feat=indexeddb
      *       https://github.com/google/lovefield/blob/master/docs/dd/02_data_store.md#25-websql-store   
      */
Initializes a database connection.
@return {!angular.$q.Promise} - promise is resolved when the db_ and noteTable_ properties have had values assigned to them

2015/10/10
When no connection options are set LoveField does some feature detection to determine which backing store to use.
If the browser supports IndexedDb it uses that, then falls back to WebSql and finally to an "in memory" data store.
I found when debugging on actual devices that LoveField chose the in memory (lf.schema.DataStoreType.MEMORY) store
on iOS which didn't work so well so here we ensure WebSql is used for iOS and Android devices.
IndexedDb seemed to work well on desktop browsers.
Initializes a database connection . @return { !angular . $q . Promise } - promise is resolved when the db_ and noteTable_ properties have had values assigned to them 2015 / 10 / 10 When no connection options are set LoveField does some feature detection to determine which backing store to use . If the browser supports IndexedDb it uses that then falls back to WebSql and finally to an " in memory " data store . I found when debugging on actual devices that LoveField chose the in memory ( lf . schema . DataStoreType . MEMORY ) store on iOS which didn ' t work so well so here we ensure WebSql is used for iOS and Android devices . IndexedDb seemed to work well on desktop browsers .
function connect() {
        var deferred = $q.defer();  
        if (isConnecting_ === false) {
          var connectionOptions = { storeType: lf.schema.DataStoreType.INDEXED_DB };
          if (service.db_ === null) {
            isConnecting_ = true;
            buildSchema()
              .connect(connectionOptions)
              .then((
                function(database) {
                  isConnecting_ = false;
                  service.db_ = database;
                  service.productTable = database.getSchema().table('products');
                  service.productVariantTable = database.getSchema().table('product_variants');
                  service.orderTable = database.getSchema().table('orders');
                  service.orderItemsTable = database.getSchema().table('order_items');
                  service.customerTable = database.getSchema().table('customers');
                  service.customerGroupTable = database.getSchema().table('customer_groups');
                  deferred.resolve();
                }));
          } else {
            deferred.resolve();
          }
        } else {
          deferred.reject('Still connecting to the database');
        }
        return deferred.promise; 
      }
function connect ( ) { var deferred = $q . defer ( ) ; if ( isConnecting_ === false ) { var connectionOptions = { storeType : lf . schema . DataStoreType . INDEXED_DB } ; if ( service . db_ === null ) { isConnecting_ = true ; buildSchema ( ) . connect ( connectionOptions ) . then ( ( function ( database ) { isConnecting_ = false ; service . db_ = database ; service . productTable = database . getSchema ( ) . table ( 'products' ) ; service . productVariantTable = database . getSchema ( ) . table ( 'product_variants' ) ; service . orderTable = database . getSchema ( ) . table ( 'orders' ) ; service . orderItemsTable = database . getSchema ( ) . table ( 'order_items' ) ; service . customerTable = database . getSchema ( ) . table ( 'customers' ) ; service . customerGroupTable = database . getSchema ( ) . table ( 'customer_groups' ) ; deferred . resolve ( ) ; } ) ) ; } else { deferred . resolve ( ) ; } } else { deferred . reject ( 'Still connecting to the database' ) ; } return deferred . promise ; }
Initializes a database connection.
Initializes a database connection .
// console.info('connect() isConnecting_', isConnecting_); // if (ionic.Platform.isIOS() || ionic.Platform.isAndroid()) { //   connectionOptions = { storeType: lf.schema.DataStoreType.WEB_SQL }; // }