@naturalcycles/db-lib 9.9.0 → 9.9.1

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.
@@ -494,23 +494,29 @@ class CommonDao {
494
494
  return await this.patchInTransaction(bm, patch, opt);
495
495
  }
496
496
  if (opt.skipDBRead) {
497
- const bmBefore = (0, js_lib_1._deepCopy)(bm);
498
- Object.assign(bm, patch);
499
- if ((0, js_lib_1._deepJsonEquals)(bm, bmBefore)) {
497
+ const patched = {
498
+ ...bm,
499
+ ...patch,
500
+ };
501
+ if ((0, js_lib_1._deepJsonEquals)(bm, patched)) {
500
502
  // Skipping the save operation, as data is the same
501
503
  return bm;
502
504
  }
505
+ Object.assign(bm, patch);
503
506
  }
504
507
  else {
505
508
  const loaded = await this.getById(bm.id, opt);
506
509
  if (loaded) {
507
- Object.assign(loaded, patch);
508
- if ((0, js_lib_1._deepJsonEquals)(loaded, bm)) {
510
+ const loadedWithPatch = {
511
+ ...loaded,
512
+ ...patch,
513
+ };
514
+ // Make `bm` exactly the same as `loadedWithPatch`
515
+ (0, js_lib_1._objectAssignExact)(bm, loadedWithPatch);
516
+ if ((0, js_lib_1._deepJsonEquals)(loaded, loadedWithPatch)) {
509
517
  // Skipping the save operation, as data is the same
510
518
  return bm;
511
519
  }
512
- // Make `bm` exactly the same as `loaded`
513
- (0, js_lib_1._objectAssignExact)(bm, loaded);
514
520
  }
515
521
  else {
516
522
  Object.assign(bm, patch);
package/package.json CHANGED
@@ -40,7 +40,7 @@
40
40
  "engines": {
41
41
  "node": ">=18.12"
42
42
  },
43
- "version": "9.9.0",
43
+ "version": "9.9.1",
44
44
  "description": "Lowest Common Denominator API to supported Databases",
45
45
  "keywords": [
46
46
  "db",
@@ -669,25 +669,32 @@ export class CommonDao<BM extends BaseDBEntity, DBM extends BaseDBEntity = BM> {
669
669
  }
670
670
 
671
671
  if (opt.skipDBRead) {
672
- const bmBefore = _deepCopy(bm)
673
- Object.assign(bm, patch)
674
- if (_deepJsonEquals(bm, bmBefore)) {
672
+ const patched: BM = {
673
+ ...bm,
674
+ ...patch,
675
+ }
676
+
677
+ if (_deepJsonEquals(bm, patched)) {
675
678
  // Skipping the save operation, as data is the same
676
679
  return bm
677
680
  }
681
+ Object.assign(bm, patch)
678
682
  } else {
679
683
  const loaded = await this.getById(bm.id, opt)
680
684
 
681
685
  if (loaded) {
682
- Object.assign(loaded, patch)
686
+ const loadedWithPatch: BM = {
687
+ ...loaded,
688
+ ...patch,
689
+ }
690
+
691
+ // Make `bm` exactly the same as `loadedWithPatch`
692
+ _objectAssignExact(bm, loadedWithPatch)
683
693
 
684
- if (_deepJsonEquals(loaded, bm)) {
694
+ if (_deepJsonEquals(loaded, loadedWithPatch)) {
685
695
  // Skipping the save operation, as data is the same
686
696
  return bm
687
697
  }
688
-
689
- // Make `bm` exactly the same as `loaded`
690
- _objectAssignExact(bm, loaded)
691
698
  } else {
692
699
  Object.assign(bm, patch)
693
700
  }