how to allow nullable for an enum field in mongoose schema?
Based on this issue I also didn't find any proper solution as this is my problem too. I believe there is no need to add null as the default value (default: null)
to fix the problem.
You can only set nullable: true
in your schema and write it more readable as below:
Object.values(SomeEnumObj).concat([null])
Your schema:
...someKey: { type: Schema.Types.String, nullable: true enum: Object.values(SomeEnumObj).concat([null]),}...