Skip to content

Commit

Permalink
fix: CommonDao.create should first assignId* then validate
Browse files Browse the repository at this point in the history
  • Loading branch information
kirillgroshkov committed Oct 1, 2022
1 parent 020afe2 commit 058d470
Show file tree
Hide file tree
Showing 2 changed files with 466 additions and 441 deletions.
7 changes: 4 additions & 3 deletions src/commondao/common.dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,10 @@ export class CommonDao<

// CREATE
create(part: Partial<BM> = {}, opt: CommonDaoOptions = {}): Saved<BM> {
let bm = this.cfg.hooks!.beforeCreate!(part) as BM
bm = this.validateAndConvert(bm, this.cfg.bmSchema, DBModelType.BM, opt)
return this.assignIdCreatedUpdated(bm, opt)
const bm = this.cfg.hooks!.beforeCreate!(part)
// First assignIdCreatedUpdated, then validate!
this.assignIdCreatedUpdated(bm as any, opt)
return this.validateAndConvert(bm, this.cfg.bmSchema, DBModelType.BM, opt)
}

// GET
Expand Down
Loading

0 comments on commit 058d470

Please sign in to comment.