primaryKeys: function()

in public/dexie.js [4335:4364]


        primaryKeys: function (cb) {
          var ctx = this._ctx;
          if (
            hasGetAll &&
            ctx.dir === "next" &&
            isPlainKeyRange(ctx, true) &&
            ctx.limit > 0
          ) {
            // Special optimation if we could use IDBObjectStore.getAllKeys() or
            // IDBKeyRange.getAllKeys():
            return this._read(function (resolve, reject, idbstore) {
              var idxOrStore = getIndexOrStore(ctx, idbstore);
              var req =
                ctx.limit < Infinity
                  ? idxOrStore.getAllKeys(ctx.range, ctx.limit)
                  : idxOrStore.getAllKeys(ctx.range);
              req.onerror = eventRejectHandler(reject);
              req.onsuccess = eventSuccessHandler(resolve);
            }).then(cb);
          }
          ctx.keysOnly = !ctx.isMatch;
          var a = [];
          return this.each(function (item, cursor) {
            a.push(cursor.primaryKey);
          })
            .then(function () {
              return a;
            })
            .then(cb);
        },