Using the following diagram:
{ data1: String, nested: { nestedProp1: String, nestedSub: [String] } }
When I do new MyModel({data1: 'something}).toObject() , the newly created document is displayed as follows:
{ '_id' : 'xxxxx', 'data1': 'something', 'nested': { 'nestedSub': [] } }
those. the attached document is created with an empty array.
How to make "nested" completely optional, i.e. not created at all if it is not specified in the input?
I do not want to use a separate scheme for "nested" ones that do not need such complexity.
source share