@naturalcycles/db-lib 8.41.0 → 8.41.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.
@@ -56,9 +56,10 @@ class CommonDao {
56
56
  }
57
57
  // CREATE
58
58
  create(part = {}, opt = {}) {
59
- let bm = this.cfg.hooks.beforeCreate(part);
60
- bm = this.validateAndConvert(bm, this.cfg.bmSchema, db_model_1.DBModelType.BM, opt);
61
- return this.assignIdCreatedUpdated(bm, opt);
59
+ const bm = this.cfg.hooks.beforeCreate(part);
60
+ // First assignIdCreatedUpdated, then validate!
61
+ this.assignIdCreatedUpdated(bm, opt);
62
+ return this.validateAndConvert(bm, this.cfg.bmSchema, db_model_1.DBModelType.BM, opt);
62
63
  }
63
64
  async getById(id, opt = {}) {
64
65
  if (!id)
package/package.json CHANGED
@@ -12,8 +12,7 @@
12
12
  "@naturalcycles/bench-lib": "^1.0.0",
13
13
  "@naturalcycles/dev-lib": "^13.0.0",
14
14
  "@types/node": "^18.0.3",
15
- "jest": "^29.0.0",
16
- "weak-napi": "^2.0.2"
15
+ "jest": "^29.0.0"
17
16
  },
18
17
  "files": [
19
18
  "dist",
@@ -42,7 +41,7 @@
42
41
  "engines": {
43
42
  "node": ">=14.15"
44
43
  },
45
- "version": "8.41.0",
44
+ "version": "8.41.1",
46
45
  "description": "Lowest Common Denominator API to supported Databases",
47
46
  "keywords": [
48
47
  "db",
@@ -106,9 +106,10 @@ export class CommonDao<
106
106
 
107
107
  // CREATE
108
108
  create(part: Partial<BM> = {}, opt: CommonDaoOptions = {}): Saved<BM> {
109
- let bm = this.cfg.hooks!.beforeCreate!(part) as BM
110
- bm = this.validateAndConvert(bm, this.cfg.bmSchema, DBModelType.BM, opt)
111
- return this.assignIdCreatedUpdated(bm, opt)
109
+ const bm = this.cfg.hooks!.beforeCreate!(part)
110
+ // First assignIdCreatedUpdated, then validate!
111
+ this.assignIdCreatedUpdated(bm as any, opt)
112
+ return this.validateAndConvert(bm, this.cfg.bmSchema, DBModelType.BM, opt)
112
113
  }
113
114
 
114
115
  // GET