Closed adrianwiechec-at-optilyz closed 12 months ago
Hi @adrianwiechec-at-optilyz, thanks for pointing this out.
I'll look at fixing this ASAP. As a workaround, you can provide required: true
.
@adrianwiechec-at-optilyz after reviewing, the current behaviour is actually correct.
If you do not specify required: true
on a field, it is not a required parameter, even if it has a default value. In this case, it is an optional field which gets initialized to a default value, but can be unset at a later point in time.
Closing this for now, let me know if you have any other questions.
That's a bummer (on Mongoose side), but thanks for looking into this! :bow:
The
default
field in schema spec seems to be ignored. For example, for the following user model:after running
npx mtgen user.js
, I get:with
firstName
as optional field, while clearly it will never actually be undefined, so I'm expecting just: