dexie 4.0.1-rc.1 → 4.0.2

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.
package/dist/dexie.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-rc.1, Wed Mar 20 2024
7
+ * Version 4.0.2, Wed Apr 10 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
package/dist/dexie.js CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * By David Fahlander, david.fahlander@gmail.com
6
6
  *
7
- * Version 4.0.1-rc.1, Wed Mar 20 2024
7
+ * Version 4.0.2, Wed Apr 10 2024
8
8
  *
9
9
  * https://dexie.org
10
10
  *
@@ -1150,7 +1150,7 @@
1150
1150
  }
1151
1151
  }
1152
1152
 
1153
- var DEXIE_VERSION = '4.0.1-rc.1';
1153
+ var DEXIE_VERSION = '4.0.2';
1154
1154
  var maxString = String.fromCharCode(65535);
1155
1155
  var minKey = -Infinity;
1156
1156
  var INVALID_KEY_ARGUMENT = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.";
@@ -4585,8 +4585,9 @@
4585
4585
  }, table: function (tableName) {
4586
4586
  var table = core.table(tableName);
4587
4587
  var schema = table.schema;
4588
- var primaryKey = schema.primaryKey;
4588
+ var primaryKey = schema.primaryKey, indexes = schema.indexes;
4589
4589
  var extractKey = primaryKey.extractKey, outbound = primaryKey.outbound;
4590
+ var indexesWithAutoIncPK = primaryKey.autoIncrement && indexes.filter(function (index) { return index.compound && index.keyPath.includes(primaryKey.keyPath); });
4590
4591
  var tableClone = __assign(__assign({}, table), { mutate: function (req) {
4591
4592
  var trans = req.trans;
4592
4593
  var mutatedParts = req.mutatedParts || (req.mutatedParts = {});
@@ -4629,6 +4630,14 @@
4629
4630
  return table.mutate(req).then(function (res) {
4630
4631
  if (keys && (req.type === 'add' || req.type === 'put')) {
4631
4632
  pkRangeSet.addKeys(res.results);
4633
+ if (indexesWithAutoIncPK) {
4634
+ indexesWithAutoIncPK.forEach(function (idx) {
4635
+ var idxVals = req.values.map(function (v) { return idx.extractKey(v); });
4636
+ var pkPos = idx.keyPath.findIndex(function (prop) { return prop === primaryKey.keyPath; });
4637
+ res.results.forEach(function (pk) { return idxVals[pkPos] = pk; });
4638
+ getRangeSet(idx.name).addKeys(idxVals);
4639
+ });
4640
+ }
4632
4641
  }
4633
4642
  trans.mutatedParts = extendObservabilitySet(trans.mutatedParts || {}, mutatedParts);
4634
4643
  return res;