create: function()

in public/dexie.js [3297:3334]


      create: function (idbtrans) {
        var _this = this;
        if (!this.mode) return this;
        assert(!this.idbtrans);
        if (!idbtrans && !idbdb) {
          switch (dbOpenError && dbOpenError.name) {
            case "DatabaseClosedError":
              // Errors where it is no difference whether it was caused by the user operation or an earlier call to db.open()
              throw new exceptions.DatabaseClosed(dbOpenError);
            case "MissingAPIError":
              // Errors where it is no difference whether it was caused by the user operation or an earlier call to db.open()
              throw new exceptions.MissingAPI(dbOpenError.message, dbOpenError);
            default:
              // Make it clear that the user operation was not what caused the error - the error had occurred earlier on db.open()!
              throw new exceptions.OpenFailed(dbOpenError);
          }
        }
        if (!this.active) throw new exceptions.TransactionInactive();
        assert(this._completion._state === null);
        idbtrans = this.idbtrans =
          idbtrans ||
          idbdb.transaction(safariMultiStoreFix(this.storeNames), this.mode);
        idbtrans.onerror = wrap(function (ev) {
          preventDefault(ev); // Prohibit default bubbling to window.error
          _this._reject(idbtrans.error);
        });
        idbtrans.onabort = wrap(function (ev) {
          preventDefault(ev);
          _this.active && _this._reject(new exceptions.Abort(idbtrans.error));
          _this.active = false;
          _this.on("abort").fire(ev);
        });
        idbtrans.oncomplete = wrap(function () {
          _this.active = false;
          _this._resolve();
        });
        return this;
      },