Skip to content

Commit

Permalink
fix(query-typegoose): ignore undefined id field in creation dto (#1165)
Browse files Browse the repository at this point in the history
  • Loading branch information
onichandame authored Jul 24, 2021
1 parent 4b98f25 commit 3d02d79
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ export class TypegooseQueryService<Entity extends Base>
}

private ensureIdIsNotPresent(e: DeepPartial<Entity>): void {
if (Object.keys(e).find((f) => f === 'id' || f === '_id')) {
if (
Object.keys(e)
.filter((v) => typeof e[v] !== `undefined`)
.find((f) => f === 'id' || f === '_id')
) {
throw new Error('Id cannot be specified when updating or creating');
}
}
Expand Down

0 comments on commit 3d02d79

Please sign in to comment.