@bitcobblers/wod-wiki-storage 0.57.2213 → 0.58.2220

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -524,7 +524,22 @@ var IDBStore = class _IDBStore {
524
524
  return (await this.owner.open()).get(this.name, key);
525
525
  }
526
526
  async getMany(keys) {
527
- if (this.tx) return Promise.all(keys.map((key) => this.tx.objectStore(this.name).get(key)));
527
+ if (this.tx) {
528
+ if (keys.length >= 64) {
529
+ const def = STORE_DEFS.find((d) => d.name === this.name);
530
+ if (def && typeof def.keyPath === "string") {
531
+ const all = await this.tx.objectStore(this.name).getAll();
532
+ const byKey = /* @__PURE__ */ new Map();
533
+ for (const row of all) {
534
+ if (row !== null && typeof row === "object") {
535
+ byKey.set(Reflect.get(row, def.keyPath), row);
536
+ }
537
+ }
538
+ return keys.map((key) => byKey.get(key));
539
+ }
540
+ }
541
+ return Promise.all(keys.map((key) => this.tx.objectStore(this.name).get(key)));
542
+ }
528
543
  return this.owner.transaction([this.name], "readonly", (tx) => tx.readonly(this.name).getMany(keys));
529
544
  }
530
545
  async getAll(query, count) {
@@ -536,7 +551,29 @@ var IDBStore = class _IDBStore {
536
551
  return (await this.owner.open()).getAllFromIndex(this.name, index, query, count);
537
552
  }
538
553
  async getAllFromIndexMany(index, keys) {
539
- if (this.tx) return Promise.all(keys.map((key) => this.tx.objectStore(this.name).index(index).getAll(key)));
554
+ if (this.tx) {
555
+ if (keys.length >= 64) {
556
+ const def = STORE_DEFS.find((d) => d.name === this.name);
557
+ const idxDef = def?.indexes?.find((i) => i.name === index);
558
+ if (idxDef && typeof idxDef.keyPath === "string" && !idxDef.multiEntry) {
559
+ const all = await this.tx.objectStore(this.name).getAll();
560
+ const byKey = /* @__PURE__ */ new Map();
561
+ for (const row of all) {
562
+ if (row !== null && typeof row === "object") {
563
+ const k = Reflect.get(row, idxDef.keyPath);
564
+ let bucket = byKey.get(k);
565
+ if (!bucket) {
566
+ bucket = [];
567
+ byKey.set(k, bucket);
568
+ }
569
+ bucket.push(row);
570
+ }
571
+ }
572
+ return keys.map((key) => byKey.get(key) ?? []);
573
+ }
574
+ }
575
+ return Promise.all(keys.map((key) => this.tx.objectStore(this.name).index(index).getAll(key)));
576
+ }
540
577
  return this.owner.transaction([this.name], "readonly", (tx) => tx.readonly(this.name).getAllFromIndexMany(index, keys));
541
578
  }
542
579
  async count(query) {