Do not write undefined values when toObject is called.
scotthovestadt opened this issue · comments
Do not write undefined values to the object because of strange behavior when using with MongoDB.
MongoDB will convert undefined to null and overwrite existing values in that field.
Added new option setUndefined
which defaults to false
.
This is technically a breaking change but I'm changing the behavior because the current behavior defaults to strange and unexpected interactions with MongoDB. Will do a full version number increment to signify the breaking change.
To get the old behavior back, use option setUndefined: true
. Use cases for old behavior:
- You want to write undefined values when exporting to JSON explicitly
- You want MongoDB to convert the undefined indexes to null and overwrite existing fields