@bitcobblers/wod-wiki-storage 0.57.2213 → 0.59.2235

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.
@@ -123,7 +123,22 @@ var IDBStore = class _IDBStore {
123
123
  return (await this.owner.open()).get(this.name, key);
124
124
  }
125
125
  async getMany(keys) {
126
- if (this.tx) return Promise.all(keys.map((key) => this.tx.objectStore(this.name).get(key)));
126
+ if (this.tx) {
127
+ if (keys.length >= 64) {
128
+ const def = STORE_DEFS.find((d) => d.name === this.name);
129
+ if (def && typeof def.keyPath === "string") {
130
+ const all = await this.tx.objectStore(this.name).getAll();
131
+ const byKey = /* @__PURE__ */ new Map();
132
+ for (const row of all) {
133
+ if (row !== null && typeof row === "object") {
134
+ byKey.set(Reflect.get(row, def.keyPath), row);
135
+ }
136
+ }
137
+ return keys.map((key) => byKey.get(key));
138
+ }
139
+ }
140
+ return Promise.all(keys.map((key) => this.tx.objectStore(this.name).get(key)));
141
+ }
127
142
  return this.owner.transaction([this.name], "readonly", (tx) => tx.readonly(this.name).getMany(keys));
128
143
  }
129
144
  async getAll(query, count) {
@@ -135,7 +150,29 @@ var IDBStore = class _IDBStore {
135
150
  return (await this.owner.open()).getAllFromIndex(this.name, index, query, count);
136
151
  }
137
152
  async getAllFromIndexMany(index, keys) {
138
- if (this.tx) return Promise.all(keys.map((key) => this.tx.objectStore(this.name).index(index).getAll(key)));
153
+ if (this.tx) {
154
+ if (keys.length >= 64) {
155
+ const def = STORE_DEFS.find((d) => d.name === this.name);
156
+ const idxDef = def?.indexes?.find((i) => i.name === index);
157
+ if (idxDef && typeof idxDef.keyPath === "string" && !idxDef.multiEntry) {
158
+ const all = await this.tx.objectStore(this.name).getAll();
159
+ const byKey = /* @__PURE__ */ new Map();
160
+ for (const row of all) {
161
+ if (row !== null && typeof row === "object") {
162
+ const k = Reflect.get(row, idxDef.keyPath);
163
+ let bucket = byKey.get(k);
164
+ if (!bucket) {
165
+ bucket = [];
166
+ byKey.set(k, bucket);
167
+ }
168
+ bucket.push(row);
169
+ }
170
+ }
171
+ return keys.map((key) => byKey.get(key) ?? []);
172
+ }
173
+ }
174
+ return Promise.all(keys.map((key) => this.tx.objectStore(this.name).index(index).getAll(key)));
175
+ }
139
176
  return this.owner.transaction([this.name], "readonly", (tx) => tx.readonly(this.name).getAllFromIndexMany(index, keys));
140
177
  }
141
178
  async count(query) {