src/batoh.js
function(cb) {
    var self = this;
    var request;
    try {
      request = IndexedDB.open(self.setup.database, self.setup.version);
    } catch (err) {
      if (isFunction(cb)) return cb(err);
    }
    request.onsuccess = function(event) {
      self.idb = event.target.result;
      if (isFunction(cb)) return cb(null);
    };
    request.onerror = function(event) {
      if (isFunction(cb)) return cb(event.target.error);
    };
    request.onblocked = function(event) {
      if (isFunction(cb)) return cb(event.target.error);
    };
    request.onupgradeneeded = function(event) {
      try {
        var idb = event.target.result;
        for (var storeName in self.setup.stores) {
          var store = self.setup.stores[storeName];
          var objectStore = idb.createObjectStore(storeName,
            { keyPath: store.keyPath, autoIncrement: store.autoIncrement });
          for (var indexNo in store.indexes) {
            var index = store.indexes[indexNo];
            objectStore.createIndex(index.name, index.keyPath,
              { unique: index.unique, multiEntry: index.multiEntry });
          }
        }
      } catch (err) {
        if (isFunction(cb)) return cb(err);
      }
    };
  }
function(cb) {
    var self = this;
    var request;
    try {
      request = IndexedDB.open(self.setup.database, self.setup.version);
    } catch (err) {
      if (isFunction(cb)) return cb(err);
    }
    request.onsuccess = function(event) {
      self.idb = event.target.result;
      if (isFunction(cb)) return cb(null);
    };
    request.onerror = function(event) {
      if (isFunction(cb)) return cb(event.target.error);
    };
    request.onblocked = function(event) {
      if (isFunction(cb)) return cb(event.target.error);
    };
    request.onupgradeneeded = function(event) {
      try {
        var idb = event.target.result;
        for (var storeName in self.setup.stores) {
          var store = self.setup.stores[storeName];
          var objectStore = idb.createObjectStore(storeName,
            { keyPath: store.keyPath, autoIncrement: store.autoIncrement });
          for (var indexNo in store.indexes) {
            var index = store.indexes[indexNo];
            objectStore.createIndex(index.name, index.keyPath,
              { unique: index.unique, multiEntry: index.multiEntry });
          }
        }
      } catch (err) {
        if (isFunction(cb)) return cb(err);
      }
    };
  }
function ( cb ) { var self = this ; var request ; try { request = IndexedDB . open ( self . setup . database , self . setup . version ) ; } catch ( err ) { if ( isFunction ( cb ) ) return cb ( err ) ; } request . onsuccess = function ( event ) { self . idb = event . target . result ; if ( isFunction ( cb ) ) return cb ( null ) ; } ; request . onerror = function ( event ) { if ( isFunction ( cb ) ) return cb ( event . target . error ) ; } ; request . onblocked = function ( event ) { if ( isFunction ( cb ) ) return cb ( event . target . error ) ; } ; request . onupgradeneeded = function ( event ) { try { var idb = event . target . result ; for ( var storeName in self . setup . stores ) { var store = self . setup . stores [ storeName ] ; var objectStore = idb . createObjectStore ( storeName , { keyPath : store . keyPath , autoIncrement : store . autoIncrement } ) ; for ( var indexNo in store . indexes ) { var index = store . indexes [ indexNo ] ; objectStore . createIndex ( index . name , index . keyPath , { unique : index . unique , multiEntry : index . multiEntry } ) ; } } } catch ( err ) { if ( isFunction ( cb ) ) return cb ( err ) ; } } ; }
Open or create the database using the `setup` passed to the constructor.

@param {Function} callback - gets one argument `(err)`,
if there is no error `err` is null.
Open or create the database using the setup passed to the constructor .