Closed LSafer closed 2 years ago
/**
* The model that `populate()` should use if populating this path.
*/
ref?: string | Model<any> | ((this: any, doc: any) => string | Model<any>);
Never mind, I created https://github.com/lsafer/mongoose-extra-validators to address the issue.
Explanation
Mongoose allows the field
ref
to be any of:Expected Behavior
When
ref
is a function, the plugin executes the function Whenref
is a model, the plugin takes the name of the modelActual Behavior
The plugin uses the
toString
function the value onref
to get the collection name