Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support model ref and function ref #42

Closed
LSafer opened this issue Apr 30, 2022 · 5 comments
Closed

Support model ref and function ref #42

LSafer opened this issue Apr 30, 2022 · 5 comments

Comments

@LSafer
Copy link

LSafer commented Apr 30, 2022

Explanation

Mongoose allows the field ref to be any of:

  • string
  • model
  • a function that returns string
  • a function that returns model

Expected Behavior

When ref is a function, the plugin executes the function
When ref is a model, the plugin takes the name of the model

Actual Behavior

The plugin uses the toString function the value on ref to get the collection name

@LSafer
Copy link
Author

LSafer commented Apr 30, 2022

    /**
     * The model that `populate()` should use if populating this path.
     */
    ref?: string | Model<any> | ((this: any, doc: any) => string | Model<any>);

@LSafer
Copy link
Author

LSafer commented Apr 30, 2022

trovafer#1

@LSafer
Copy link
Author

LSafer commented Apr 30, 2022

@LSafer
Copy link
Author

LSafer commented Apr 30, 2022

#41

@LSafer
Copy link
Author

LSafer commented May 5, 2022

Never mind, I created https://github.com/lsafer/mongoose-extra-validators to address the issue.

@LSafer LSafer closed this as completed May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant