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

need to invoke a method on referenced collection before populate when using mongoose #82

Open
DavidHuang2002 opened this issue Feb 10, 2024 · 0 comments
Labels
invalid This doesn't seem right

Comments

@DavidHuang2002
Copy link
Collaborator

Before populating the referenced field with a collection, the referenced collection needed to be registered, currently, to do that, we run some find a method that has no consequence, otherwise, we can get a Model not registered error. It can be pretty confusing in code.

Screenshot 2024-02-10 at 4 43 50 PM Screenshot 2024-02-10 at 4 43 27 PM

I think the cause of this problem is that the a schema is only registed to a model when we first import it and invoke a method on it, which might not have happened when we run populate. I think can be fixed by running all model registration statement(like the following) when the server first starts.
Screenshot 2024-02-10 at 4 54 11 PM

@JiashuHarryHuang JiashuHarryHuang added the invalid This doesn't seem right label Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants