@workglow/indexeddb 0.3.21 → 0.3.23

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.
@@ -1293,6 +1293,14 @@ class IndexedDbTabularStorage extends BaseTabularStorage {
1293
1293
  }
1294
1294
  });
1295
1295
  }
1296
+ async updateWhere(match, patch) {
1297
+ this.assertPatchKeepsPrimaryKey(patch);
1298
+ const matches = await this.query(match) ?? [];
1299
+ if (matches.length === 0)
1300
+ return;
1301
+ const updated = { ...matches[0], ...patch };
1302
+ return this.put(updated);
1303
+ }
1296
1304
  getEqualityCriterionValue(criteria, column) {
1297
1305
  const criterion = criteria[column];
1298
1306
  if (criterion === undefined)
@@ -1597,6 +1605,7 @@ import {
1597
1605
  getMetadataProperty,
1598
1606
  getVectorProperty,
1599
1607
  matchesFilter,
1608
+ safeEmit as safeEmit2,
1600
1609
  validateVectorEntities
1601
1610
  } from "@workglow/storage";
1602
1611
  import { createServiceToken as createServiceToken3 } from "@workglow/util";
@@ -1635,7 +1644,8 @@ class IndexedDbVectorStorage extends IndexedDbTabularStorage {
1635
1644
  const allEntities = await this.getAll() || [];
1636
1645
  for (const entity of allEntities) {
1637
1646
  const vector = entity[this.vectorPropertyName];
1638
- const metadata = this.metadataPropertyName ? entity[this.metadataPropertyName] : {};
1647
+ const rawMetadata = this.metadataPropertyName ? entity[this.metadataPropertyName] : undefined;
1648
+ const metadata = rawMetadata ?? {};
1639
1649
  if (filter && !matchesFilter(metadata, filter)) {
1640
1650
  continue;
1641
1651
  }
@@ -1650,6 +1660,7 @@ class IndexedDbVectorStorage extends IndexedDbTabularStorage {
1650
1660
  }
1651
1661
  results.sort((a, b) => b.score - a.score);
1652
1662
  const topResults = results.slice(0, topK);
1663
+ safeEmit2(this.events, "similaritySearch", query, topResults);
1653
1664
  return topResults;
1654
1665
  }
1655
1666
  }
@@ -1670,4 +1681,4 @@ export {
1670
1681
  IDB_KV_REPOSITORY
1671
1682
  };
1672
1683
 
1673
- //# debugId=43B855CF3D1C120364756E2164756E21
1684
+ //# debugId=E13F90B4076DCB4E64756E2164756E21