@naturalcycles/db-lib 8.44.0 → 8.45.0

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.
@@ -486,9 +486,6 @@ class CommonDao {
486
486
  }
487
487
  assignIdCreatedUpdated(obj, opt = {}) {
488
488
  const now = Math.floor(Date.now() / 1000);
489
- if (this.cfg.createId) {
490
- obj.id ||= this.cfg.hooks.createNaturalId?.(obj) || this.cfg.hooks.createRandomId();
491
- }
492
489
  if (this.cfg.created) {
493
490
  ;
494
491
  obj['created'] ||= obj['updated'] || now;
@@ -498,6 +495,9 @@ class CommonDao {
498
495
  obj['updated'] =
499
496
  opt.preserveUpdatedCreated && obj['updated'] ? obj['updated'] : now;
500
497
  }
498
+ if (this.cfg.createId) {
499
+ obj.id ||= this.cfg.hooks.createNaturalId?.(obj) || this.cfg.hooks.createRandomId();
500
+ }
501
501
  return obj;
502
502
  }
503
503
  // SAVE
package/package.json CHANGED
@@ -41,7 +41,7 @@
41
41
  "engines": {
42
42
  "node": ">=14.15"
43
43
  },
44
- "version": "8.44.0",
44
+ "version": "8.45.0",
45
45
  "description": "Lowest Common Denominator API to supported Databases",
46
46
  "keywords": [
47
47
  "db",
@@ -608,10 +608,6 @@ export class CommonDao<
608
608
  assignIdCreatedUpdated(obj: DBM | BM | Unsaved<BM>, opt: CommonDaoOptions = {}): DBM | Saved<BM> {
609
609
  const now = Math.floor(Date.now() / 1000)
610
610
 
611
- if (this.cfg.createId) {
612
- obj.id ||= this.cfg.hooks!.createNaturalId?.(obj as BM) || this.cfg.hooks!.createRandomId!()
613
- }
614
-
615
611
  if (this.cfg.created) {
616
612
  ;(obj as any)['created'] ||= (obj as any)['updated'] || now
617
613
  }
@@ -621,6 +617,10 @@ export class CommonDao<
621
617
  opt.preserveUpdatedCreated && (obj as any)['updated'] ? (obj as any)['updated'] : now
622
618
  }
623
619
 
620
+ if (this.cfg.createId) {
621
+ obj.id ||= this.cfg.hooks!.createNaturalId?.(obj as BM) || this.cfg.hooks!.createRandomId!()
622
+ }
623
+
624
624
  return obj as any
625
625
  }
626
626