Closed bigslycat closed 7 years ago
Hi @figliohulio.
Thanks so much for submitting this!
Can you please add test cases for the situations this fixes? That way, we'll make sure not to break those situations if we need to tweak this code again in the future (since, as you can see, the Mongoose schema code is quite finicky).
schemaType.options.type[0].ref
is only present in the case of relationship with another model, and is absent in the other cases (single relationship, array of symple types or subdocs). In the case when the field is a sub-document, relationship with another model or an array of sub-documents or relationships, we do not need to touch anyschemaType.options.type[0].ref
, orschemaType.options.type[0].name
:However, if the field will be an array of relationships, the
typeOptions.name
will be equal toundefined
. We should not really worry about it, since under this condition to baseType is no longer appeals. But this implicit behavior, which in the further development can lead to errors. That it could not happen, we need to explicitly specify the behavior for this case.